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 + true = 2 (true becomes 1)
Did you get it right? Tell me in the comments π
Follow for JS Quiz #3!
#javascript #shorts #coding #programming #webdevelopment #js #jsquiz #frontend #learnjavascript #codingtipsΒ 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 + true = 2 (true becomes 1)
Did you get it right? Tell me in the comments π
Follow for JS Quiz #3!
#javascript #shorts #coding #programming #webdevelopment #js #jsquiz #frontend #learnjavascript #codingtipsΒ Close description
