cycold / cycold.github.io

Please dot not star...
4 stars 1 forks source link

js var声明提升 #142

Closed cycold closed 6 years ago

cycold commented 7 years ago
boo = "h"
var boo = "hello"

=>>> var 声明总是提升到最上面(永远是先声明提升到最上面,然后再逐行赋值)

var boo
boo = "h"
boo = "hello"

但是let就不是这样

boo = "h"
let  boo = "hello"
// 这样就是直接报错了:  <- ReferenceError: there is not defined
// 因为这里的boo还没有声明呢 不能这么赋值: boo = "h"