I have the following code:
var cards = [
{
name: 'John',
age: 26
},
{
name: 'Marc',
age: 27
},
{
name: 'Nathan',
age: 21
}
];
var save = cards;
for(var i = 0;i < cards.length; i++){
if(i == 0){
cards.splice(i,1);
}
}
cards = save;
And at the end cards and save are the same, Marc and Nathan. And I want my cards be the array it was before, but I can't understand why it is not.
Here is a jsfiddle: https://jsfiddle.net/6g8bkauo/