What is the temporal dead zone?

后端 未结 3 1243
甜味超标
甜味超标 2020-11-21 10:10

I\'ve heard that accessing let and const values before they are initialized can cause a ReferenceError because of something called the

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-21 10:38

    Hoisting:
    let,const,var are all get hoisted process.
    (whats mean they go upper and declare in the top of the scope.)

    Initialisation:

    • var go also through the initial process, and get initial value of undefined.
    • while let,const didn't go throw the initial process, so their values are still inaccessible, although they already declared. whats put them in temporal dead zone

    So in shortly:

    hoisting process: var, let, const
    Initialisation process: var

提交回复
热议问题