views:

51

answers:

3

I have this code:

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 } ] 

How would I be able to remove some an object from the array under pinpoints.

A: 

You can use the jQuery filter() method to remove elements. It takes a selector, or a function as input.

g.d.d.c
+4  A: 

You can use pop() to remove the last element of the array, or you can use the splice() method to remove a specific element.

For example,

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

pinpoints.splice(3, 10);  // removes ten elements, starting at index 3.
womp
+1 please mention too you did not use jQuery..
Reigel
+2  A: 

grep should work for you too

http://api.jquery.com/jQuery.grep

PeterWong