I want to construct an object, where one of the property is going to be an array:
var a = 1;
var b = ["a","b"]
var b1 = ["c","d"]
var c = {}
I want the object c to be like this:
{"prop":1, prop1: ["ac","bd"]}
I tried doing it like this:
c.prop = a;
for (var index = 0 ; index < b.length; index++){
c.prop1[index] = b[index] + b1[index];
}
c.prop = a; c.prop1 = b?c.prop1before yourforloop? Ifc.prop1isn't defined yet, you can't set properties on it withc.prop1[index] = ..., and you'll see errors in your JavaScript console to that effect.