var arr = [{
key: "key1", value: "z"
}, {
key: "key2", value: "u"
}, {
...
}];
How to check whether my key:"key1" exists already or not. If it does not exist, i need to add the key in ma array.
if(arr.hasOwnProperty("key1")){
arr.unshift({key:"key1", value:"z"});
}
Since you’ve got an Array filled with Objects, you need to do it like:
(ES3)