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.
If you are trying to embed a variable to the window. You can use this http://jsfiddle.net/XJEGU/3/
精彩评论