-1

I tried to use "delete" method on 1,2,4 which would left 0..3..5 instead of 0..1..2..3. How do you remove it properly?

http://s22.postimg.org/8zydta9bl/image.png

James Lei
  • 300
  • 2
  • 5
  • 14
  • Google for "remove index in array object". –  Dec 23 '15 at 09:31
  • @torazaburo I think my question has nothing to do with array. – James Lei Dec 23 '15 at 12:44
  • You yourself specified Array in the title of your question. Then you refer to "removing an index", where index is a notion specific to arrays (if a standard object, it would be called a "key"). Then you show syntax such as `oItem[0]`, which is an access to an array element. All the people that marked your question as a duplicate thought it was about arrays, because they specified a duplicate that is about arrays. The person that answered thought it was about arrays. So, in what way does your question have nothing to do with arrays? –  Dec 23 '15 at 12:49
  • @torazaburo It seem to have an object contains array and objects in it, please see my update picture in my question. – James Lei Dec 23 '15 at 13:00
  • Please delete this question and open a new one. This one has already been closed. –  Dec 23 '15 at 13:06

1 Answers1

1

Please try this

var index = array.indexOf(oItem[2]);
if (index > -1) {
    array.splice(index, 1);
}

The splice() method changes the content of an array by removing existing elements and/or adding new elements.

DEMO

Rino Raj
  • 6,041
  • 2
  • 22
  • 37