gpt4 book ai didi

javascript - JS 奇怪的行为

转载 作者:数据小太阳 更新时间:2023-10-29 05:54:17 28 4
gpt4 key购买 nike

<分区>

有人可以帮助我 - 为什么我们在 JS 片段中有这种行为?

var foo = function() {
return {
hi: console.log("foo")
}
}

var foo1 = function() {
return
{
hi: console.log("foo1")
}
}

foo();
foo1();

为什么只打印“foo”?

fiddle

编辑好的,这是因为自动分号插入,但是

我们有没有办法强制 JS 不执行这种情况?

我的意思是,我们可以做一些会在这里抛出错误的事情吗?

EDIT2

看起来最好的建议是 JShint - 我问了 here

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com