JavsScript - 函数与函数表达式

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <script>
        function hello(name){
            document.write(name + '欢迎您~');
        }
        hello('齐小帅');   //调用函数
        
        //将函数写成表达式,放在对象中
        var hei = function hei (site) {
            document.write(site + '欢迎您');
        };
        hei('hello~');
    </script>
</body>
</html>

运行结果:齐小帅欢迎您~hello~欢迎您

猜你喜欢

转载自blog.csdn.net/Qjy_985211/article/details/83756825
今日推荐