jeudi 13 août 2015

JQuery remove key and its value from an Array

I am trying to figure out how to remove a key called age from an array.

I tried below splice, but didnt help me removing the key and retain other keys and values in an array.

$(data).splice("age",1);

Here is my full code that outputs an array

var data = {'fname': 'John', 'lname': 'Smith', 'age': 29, 'job': 'Agent' };

$(data).splice("age",1);

console.log(data);

Here is JSFiddle link that demonstrates above example.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire