奇怪的是,以下代码在最新的Chrome浏览器中没有出现任何错误:
function func(){
x:1
}
func();
Run Code Online (Sandbox Code Playgroud)
究竟发生了什么?(我不是试图在函数中添加属性,我知道如何使用func.property或者arguments.callee.property)
更新:如果x:1是labeled statement,那么
function func(){
1
}
Run Code Online (Sandbox Code Playgroud)
被认为是有效的功能.这是1做什么的?它被忽略了吗?这是陈述,表达还是其他什么?
你的路线
x:1
Run Code Online (Sandbox Code Playgroud)
是一个带标签的声明.
示例:
var i = 0;
var j = 8;
checkiandj: while (i < 4) {
console.log("i: " + i);
i += 1;
checkj: while (j > 4) {
console.log("j: " + j);
j -= 1;
if ((j % 2) == 0)
continue checkj;
console.log(j + " is odd.");
}
console.log("i = " + i);
console.log("j = " + j);
}Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
55 次 |
| 最近记录: |