push key value into array javascript code example
Example 1: jquery add to array with key
var obj = {};
$.getJSON("displayjson.php",function (data) {
$.each(data.news, function (i, news) {
obj[news.title] = news.link;
});
});
// later:
$.each(obj, function (index, value) {
alert( index + ' : ' + value );
});
Example 2: javascript push array with key name
arr["key"] = "value";