I'm trying to add an array to my existing array. This works in a strange way. The number of an array is added to the existing array, but all the existing arrays have their values changed to the value of the last added array :(
var BigArray = [];
var myArray = [];
function clickBtn(){
myArray["fixedName"] = Math.random() * 5;
addArray();
}
function addArray() {
BigArray = BigArray.concat([myArray]);
console.log(BigArray);
}
<button onclick="clickBtn()">click me</button>
It will be added after a few clicks on the button. Although all data is different, all arrays added to BigArray are the same!