【发布时间】:2016-07-02 14:55:26
【问题描述】:
我想删除一个数组条目。 已经用过拼接方法了,还是不行。
var clients = new Array();
//-----
var tmp = new Array();
tmp["connection"] = connection;
tmp["authentificated"] = 1;
tmp["username"] = rows[0].username;
tmp["rank"] = rows[0].rank;
clients.push(tmp);
这不起作用:
clients.splice(index, 1);
你有什么想法,错误在哪里?
提前致谢。
【问题讨论】:
-
好吧,
index上有什么内容? -
最好将
tmp用作对象而不是数组。 -
数组中有一个数组。致电
delete clients[0]['username'];或使用对象。 -
“这行不通”。显示minimal reproducible example
-
谢谢大家。你是对的。对“索引”的解释会很有帮助。
标签: javascript arrays