CJCoding With Joseph
← Back to Question List
JavaScript Code Walkthrough #45

Array Aliasing vs a Copy

mediumArrays

📄 Code

Read carefully — what does this print?
1let a = [1, 2, 3];
2let b = a;
3b.push(4);
4console.log(a.length);
5console.log(a[3]);
6let c = a.slice();
7c.push(5);
8console.log(a.length);

🎯 Your Answer