我有以下对象:删除项目对象的JavaScript
[{
"id": 2,
"price": 2000,
"name": "Mr Robot T1",
"image": "http://placehold.it/270x335"
}, {
"id": 1,
"price": 1000,
"name": "Mr Robot T2",
"image": "http://placehold.it/270x335"
}]
和我要的是删除第一个项目(ID = 1),结果是:
[{
"id": 2,
"price": 2000,
"name": "Mr Robot T1",
"image": "http://placehold.it/270x335"
}]
,因为它可以做?
转到MDN并阅读有关Array.prototype。不要跑到stackoverflow问这样的基本问题。此外,这与jQuery没有任何关系。 – Azamantes
你有一个对象数组,而不仅仅是一个对象。您要求删除数组中的一个索引项目。参见:['Array.prototype.splice()'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) – Makyen
Bonsoir Elliot:'array.splice (0,1)' – jrbedard