问题
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 anybody tell what jsfiddle does with this code for such behavior.
回答1:
JSFiddle wraps code in a function. This means that x
is scoped locally to that function.

回答2:
If you are trying to embed a variable to the window. You can use this http://jsfiddle.net/XJEGU/3/
来源:https://stackoverflow.com/questions/6971543/whats-wrong-with-this-code-in-jsfiddle