EveryDay
EveryDay copied to clipboard
let和const不会变量提升
https://github.com/WindrunnerMax/EveryDay/blob/master/JavaScript/ES6%E6%96%B0%E7%89%B9%E6%80%A7.md 这里写到“var会变量提升,let与const也存在变量提升但有所不同。” 但是参考 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/let#%E6%8F%8F%E8%BF%B0 其实是不会提升的
建议你去阅读英文原文,关于你这块,MDN
的描述是
The other difference between var and let is that the latter is initialized to a value only when a parser evaluates it (see below).
他并没有对于变量提升的相关描述,如果你纠结于这个问题,不如去阅读 https://stackoverflow.com/questions/31219420/are-variables-declared-with-let-or-const-hoisted 的相关讨论