views:

906

answers:

2

I am trying to remove an object from an array. but from some reason its not working. I am under the impression that a splice accepts 2 parameters. the position of the array. and for parameter 2 , how many to delete from then on out

I just want to delete one array so I am doing this

array.splice(i,0);

but it isn't working. can someone tell me what i am doing wrong. enlighten me on how it suppose to work. thanks

+6  A: 

If you want to remove one element, you call splice(index, 1).

Anon.
You beat me to it...
Moshe
+1  A: 

My first question is: what is 'i'? Check where that is coming from.

Also, you should probably use 1 for the second parameter, not 0. The current code you have says:

`array.splice(,0)`

or,

`delete zero elements from position i and on`.

Deleting zero things is what you are describing, no? Change it to one and:

`array.splice(i,1)`

or

`Delete on element from position i and on`.
Moshe