3 回答
TA贡献1784条经验 获得超9个赞
var
var
delete
var
var
var
TA贡献1895条经验 获得超7个赞
var
var
var foo = 'first time use';foo = 'second time use';
window
var foo = "I'm global";var bar = "So am I";function () { var foo = "I'm local, the previous 'foo' didn't notice a thing"; var baz = "I'm local, too"; function () { var foo = "I'm even more local, all three 'foos' have different values"; baz = "I just changed 'baz' one scope higher, but it's still not global"; bar = "I just changed the global 'bar' variable"; xyz = "I just created a new global variable"; }}
functions
TA贡献1836条经验 获得超4个赞
myObj = 1;
external = 5;function firsttry() { var external = 6; alert("first Try: " + external);}function secondtry() { external = 7; alert("second Try: " + external);}alert(external); // Prints 5firsttry(); // Prints 6alert(external); // Prints 5secondtry(); // Prints 7alert(external); // Prints 7
添加回答
举报