标签:uncaught col var ref bsp enc efi function span
function test(){ var temp = "dsd"; #局部 console.log(temp); } test() /*dsd*/ console.log(temp) /*无法输出,变量为声明*/ /* Uncaught ReferenceError: temp is not defined */
function test(){ temp = "dsd"; #全局 console.log(temp); } test() /*dsd*/ console.log(temp) /*dsd*/
function test(){ window[‘temp‘]= "dsd"; console.log(window[‘temp‘]); } test() /*dsd*/ console.log(window[‘temp‘]) /*dsd*/
function test(){ v = "dsadas" console.log(v) } test() /*dsadas*/ console.log(v) /*dsadas*/ console.log(window.v) /*dsadas*/ console.log(window[‘v‘]) /*dsadas*/
标签:uncaught col var ref bsp enc efi function span
原文地址:https://www.cnblogs.com/ssyfj/p/9073614.html