Sunday, 30 April 2017

How to remove an element from a javascript array

I have an array as below

var array = [];

var item1 = 'k1';
var itemvalue1 = {'key1':'value1'};
array[item1] = itemvalue1;

var item2 = 'k2';
var itemvalue2 = {'key2':'value2'};
array[item2] = itemvalue2;

Two questions...

  1. How to get the position(index) of the item2 in the array
  2. How to remove the item item2 from the array

Any help is appreciated.



via Riyas

No comments:

Post a Comment