开发者

Whats wrong with this code in jsfiddle

var x = "window.Something";

alert(window.x)

when i try this code in jsfiddle http://jsfiddle.net/XJEGU/, it alerts undefined. While when i run this code in my browser, it works fine, can any开发者_StackOverflow社区body tell what jsfiddle does with this code for such behavior.


JSFiddle wraps code in a function. This means that x is scoped locally to that function.

Whats wrong with this code in jsfiddle


If you are trying to embed a variable to the window. You can use this http://jsfiddle.net/XJEGU/3/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜