可以肯定,这是一个奇怪的现象。首先,我使用的是 Chrome 版本 23.x,还没有尝试在其他浏览器中重现此功能。
我从表单的服务器收到一个 JSON 数组:
JSON
{
"layout":0,
"caption":"Work History",
"cols":[
{"field":"company","label":"Company Name","hidden":false,"order":-1,"validationType":2,"list":[]}, {"field":"date_start","label":"From","hidden":false,"order":-1,"validationType":1,"list":[]},
{"field":"date_end","label":"Until","hidden":false,"order":-1,"validationType":0,"list":[]},
{"field":"position","label":"Title","hidden":false,"order":-1,"validationType":2,"list":[]},
{"field":"description","label":"Description","hidden":false,"order":-1,"validationType":0,"list":[]},
{"field":"project","label":"Project","hidden":false,"order":-1,"validationType":64,"list":[]}
]
}
然后,我尝试使用 Javascript 循环遍历 cols 对象"
Javascript
for (var c in json.cols) {
console.log("col name: " + c);
}
谷歌浏览器的控制台打印以下内容:
输出
col name: 0
col name: 1
col name: 2
col name: 3
col name: 4
col name: 5
col name: remove
首先,应该只有 6 个输出。其次,这个最终的“删除”密钥从何而来?为什么要上市?