很简单的一段代码, 变量在 同名函数声明前和声明后的 log 结果不一样, 具体的原理是什么呢?function a 声明语句的前后发生了啥?谢谢指教
实例
// 在 html 里面执行 if?(true)?{ a?=?1 document.write(window.a);?//?undefined function a()?{?} document.write(window.a);?//?1 }
你可以参考 MDN API/Document/write 来进一步了解 write API,希望可以帮到你。
1.2m questions
2.1m answers
5 comments
56.1k users