有人可以帮助我 - 为什么我们在JS片段中有这种行为?
var foo = function() {
return {
hi: console.log("foo")
}
}
var foo1 = function() {
return
{
hi: console.log("foo1")
}
}
foo();
foo1();
Run Code Online (Sandbox Code Playgroud)
为什么只打印"foo"?
编辑 确定,这是因为自动分号插入,但是
我们有办法强制JS不执行这种情况吗?
我的意思是,我们可以做一些会在这里抛出错误的东西吗?
EDIT2
看起来最好的建议是JShint - 我问这里
我注意到JS中的这种行为:
alert (new Array() == false); // true
Run Code Online (Sandbox Code Playgroud)
有人可以解释 - 为什么?我甚至不知道如何google它.
编辑
你试图说,那new array() == [],但为什么:
var someVar = [];
alert (someVar == false); // true
Run Code Online (Sandbox Code Playgroud)
我没有看到它
javascript ×2