js基本函数形式

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 无参数无返回值
         add();
        function add(){
            console.log('hello word');
        }
        add();

        //有参数无返回值
        function minus(a, b){
            console.log(a - b);
            console.log(a);
            console.log(b);
        }
        minus(10);

        // 无参数有返回值
        function edit(){
            var a = 10;
            var b = 12;
            return a * b;
        }
        var num = edit();
        console.log(num);


        // 有参数有返回值
        function nus(a, b){
            return a % b;
        }

        console.log(nus(34,12));


    </script>
</body>
</html>
©️2020 CSDN 皮肤主题: 1024 设计师:上身试试 返回首页