LoginSignup
0
0

More than 5 years have passed since last update.

Hoisting 宣告提升 By 彭彭 25

Posted at
11. 前端工程師面試常見
    a. 變數 與函式的宣告提升
    //b. 閉包 Closure 的觀念與用途 どこ?

WS000023.JPG

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"></meta>
    <title>宣告提升 Hoisting</title>
    <script type="text/javascript">

    /*x=1127; // 給定初始資料
    alert(x); // 使用變數
    var x; // 宣告變數 就算宣告寫在後面也ok 自動提升到最前面 這個就叫做hoisting
    */
    // 宣告變數同時給定初始資料 並置於下面  undefined
    // var x=10; 

    /////////////////////////////////////////////////////////////
    /*test();//前置ok
    function test(){
    alert("hello florence");
    }
    */
    // 這樣是不ok
    test();
    var test = function(){
    alert("florence")
    }

    </script>
</head>
<!-- 網頁初始化 首頁的顯示 -->
<body>
</body>
</html>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0