javascript append to json array code example

Example 1: push json into json

//create object
var myObj = {
    "artist" : artist,    //your artist variable
    "song_name" : title   //your title variable
};
//push the object to your array
favorites.push( myObj );

Example 2: push object to json array

var feed = {created_at: "2017-03-14T01:00:32Z", entry_id: 33358, field1: "4", field2: "4", field3: "0"};

var data = [];
data.push(feed);

console.log(data);

Example 3: javascript append to json

let test = {
		name: 'NN',
  		email: '[email protected]'
};

test.phone = '234654234';

// result { "name": "NN", "email": "[email protected]", "phone": "234654234" }