I have array of array and i want to add data to inner array in javascript. Suppose my code is the following:
self.basketsArray = [];
self.newCollection = {
books: []
};
self.basketsArray.push(self.newCollection);
function addNewCollection(){
self.basketsArray.push(self.newCollection);
}
function addDataToArray(index,index2){
self.basketsArray[index].books.splice(index2, 1, data);
}
In fact, when I want to add data to the inner array it adds to first inner array. What is my problem?
addDataToArray? can you provide sample input and sample output for this?