How to add an object into an object
- by FlyingCat
I am trying to add an object into another object.
My previous post helped me on the array issue but I also need to add object into an object too.
I have something like
var temp = {};
for(var i=0; i<test.length; i++){
console.log(test[i])
console.log(product[i])
temp.test[i] =product[i];
}
Both of console.log show values. However, I am getting
"Uncaught TypeError: Cannot set property '0' of undefined" for the temp.test[i] =product[i]
Can someone help me out on this? Thanks a lot