I've a strange problem while assigning the object to array in JavaScript here is complete code
var co = {'yAxis':10};
var dynCharts = new Array();
for (var x=0; x<2; x++){
dynCharts[x] = co;
}
//assigning to first array only
dynCharts[0].yAxis = { 'a':'1'};
//now alert second array
alert(dynCharts[1].yAxis.a);
If you above example code first of all I've a object called co then i'm assigning that object to arrays. Now I want to change the property called yAxis of first array but it's changing the value for the yAxis object of second array too.
JSfiddle of this code is here : http://jsfiddle.net/qvKaZ/
Can somebody please help me why its happening how to do it in property way ?