全局变量如何声明
321kaylee opened this issue · comments
321kaylee commented
Challenge Local Scope and Functions has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
function myFunction() {
var myVar="use strict";
console.log(myVar);
}
myFunction();
// 请先运行这段代码,并在左边的输出区域或浏览器的控制台中查看输出
// 由于 myVar 在 myFunction 内外均没有定义,因此才会有报错
// 现在,在 myFunction 中定义 myVar,并删掉 myFunction 外面的 console.log 那一行