jsfiddle中的这段代码有什么问题 [英] Whats wrong with this code in jsfiddle
本文介绍了jsfiddle中的这段代码有什么问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var x = "window.Something";
alert(window.x)
当我在jsfiddle http://jsfiddle.net/XJEGU/中尝试此代码时,它会发出未定义的警报.当我在浏览器中运行此代码时,它可以正常工作,任何人都可以告诉jsfiddle使用此代码来实现这种行为.
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.
推荐答案
JSFiddle将代码包装在函数中.这意味着x
在本地作用于该函数.
JSFiddle wraps code in a function. This means that x
is scoped locally to that function.
这篇关于jsfiddle中的这段代码有什么问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文