如何从jquery中的对象数组中删除对象?

ant*_*liu 1 javascript jquery jquery-plugins

我有这个代码:

var pinpoints= [ { "top": 50,
                           "left": 161,
                           "width": 52,
                           "height": 37,
                           "text": "Spot 1",
                           "id": "e69213d0-2eef-40fa-a04b-0ed998f9f1f5",
                           "editable": true },
                         { "top": 0,
                           "left": 179,
                           "width": 68,
                           "height": 74,
                           "text": "Spot 2",
                           "id": "e7f44ac5-bcf2-412d-b440-6dbb8b19ffbe",
                           "editable": true } ] 
Run Code Online (Sandbox Code Playgroud)

我怎样才能从数组中删除一些对象pinpoints.

wom*_*omp 5

您可以使用pop()删除数组的最后一个元素,也可以使用该splice()方法删除特定元素.

例如,

pinpoints.splice(1, 1);   // removes element with index 1

pinpoints.splice(3, 10);  // removes ten elements, starting at index 3.
Run Code Online (Sandbox Code Playgroud)