Skip to content
Y
yTube.SITE v8.0.4
media / worlds / tools / internet oddities
YouTube / video information

This JavaScript Mistake Breaks Real Apps 😱 JS Quiz #2

Video information, playback and saved actions.

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
Β Β Β Β Β Β 
Videos related to "This JavaScript Mistake Breaks Real Apps 😱 JS Quiz #2"

Related videos are temporarily unavailable.

Try again, or come back later.