I created two different variables a and b and in first for loop, I placed a.push and then a.unshift and in second for loop, I placed b.unshift first and then b.push but why the both variables (a and b) output will be same as [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let a = [];
for(let i=0 ; i <=10 ; i++) {
a.push(i);
a.unshift(i);
}
console.log(a);
let b = [];
for(let j=0 ; j <=10 ; j++) {
b.unshift(j);
b.push(j);
}
console.log(b);