TO delete a particular element in javascript array, find the index of that element and the use splice method
For example:
var sample_array = ['one', 'two', 'three'];
var index = sample_array.indexOf(id);
sample_array.splice(index, 1);
Note ; Splice method can be used other different cases of accessing and deleting element with help of parameters. Refer Splice() reference.
For example:
var sample_array = ['one', 'two', 'three'];
var index = sample_array.indexOf(id);
sample_array.splice(index, 1);
Note ; Splice method can be used other different cases of accessing and deleting element with help of parameters. Refer Splice() reference.
No comments:
Post a Comment