JS变量提升test2

<!--@description-->
<!--@author beyondx-->
<!--@date Created in 2022/07/30/ 23:01-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>变量提升test1</title>
</head>
<body>
    <script>
        console.log(a); // undefined
        function a() {
            console.log('aaaa');
        }
        // 函数 与 变量 同名, 函数声明 会 替换 变量声明
        // 赋值在最后
        var a = 1;
        console.log(a); // 1
    </script>
</body>
</html>

posted on 2022-07-30 23:12  beyondx  阅读(3)  评论(0编辑  收藏  举报

导航