This JavaScript Mistake Breaks Real Apps ๐ฑ JS Quiz #2
Description: let a = [1, 2, 3];
let b = a;
b.push(4);
console.log(a); // ?
Most devs get this wrong ๐
โ b = a doesn't copy the array. It gives the same array a second name.
๐ Change b โ a changes too.
โ Real copy: let b = [...a];
๐ JS Quiz #1 answer: true + tr ...ย Close description
let b = a;
b.push(4);
console.log(a); // ?
Most devs get this wrong ๐
โ b = a doesn't copy the array. It gives the same array a second name.
๐ Change b โ a changes too.
โ Real copy: let b = [...a];
๐ JS Quiz #1 answer: true + tr ...ย Close description
