1

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.

1
  • Which object do you want to remove? Commented Jul 6, 2010 at 2:52

3 Answers 3

5

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.
Sign up to request clarification or add additional context in comments.

Comments

2

grep should work for you too

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

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.