add object to another array of objects in javascript -
can 1 please me how add objects array of objects
myarray = [ { "a" :{ values }, "b" :{ values }, "c":{ values } } ]
another object:
{ "d":{ values }, "e":{ values } }
i want add next objects d , e array of first object.
it shuold this
[ { "a":{}, "b":{}, "c":{}, "d":{}, "e":{} } ]
cna me 1 how add objects
thanks in advance
according understanding have 1 array of object i.e.
myarray = [{"a" :{},"b" :{},"c":{}}]
and want add property in object use
myarray[0].d={}; myarray[0].e={}; console.log(myarray[0]);
and if want add more objects in array use push method
var obj={"a1" :{},"b1" :{},"c1":{}}
if want add in myarray use
myarray.push(obj);
yours array of object be
myarray = [{"a" :{},"b" :{},"c":{}}, {"a1" :{},"b1" :{},"c1":{}}]
hope clears yours doubt.
Comments
Post a Comment