The JavaScript Spread Operator - One Thing You DIDN'T KNOW!

  Рет қаралды 25,803

James Q Quick

James Q Quick

2 жыл бұрын

Did you really understand how the spread operator works in JavaScript? It's great for making copies of shallow objects and arrays, but can it be used to make a deep clone?
Spread Syntax Docs - developer.mozilla.org/en-US/d...
_____________________________________________
Newsletter 🗞
Interested in exclusive content and discounts? 🤯 Sign up for the newsletter!
www.jamesqquick.com
_____________________________________________
Connect with me 😀
Live streams on Twitch - / jamesqquick
Follow me on Twitter - / jamesqquick
Join the 💬 Discord Server 💬 - / discord
_____________________________________________
COURSES 💻
Learn how to build Fullstack apps with React and Serverless Functions - www.jamesqquick.com/courses/r...
Learn everything you need to know about Visual Studio Code - www.udemy.com/learn-visual-st...
Build a Quiz App - www.udemy.com/build-a-quiz-ap...

Пікірлер: 64
@solvedfyi
@solvedfyi 2 жыл бұрын
I hate clicking dislike on videos of creators trying to share tidbits with the learning public. But I hate more the padding, spending a minute telling me to guess what I don't know, many minutes setting up a scenario, then finally punching in something I yes most definitely did know and is not rare knowledge to most that have completed introductory reading on the topic. There has to be a better way. I promise if you just tell us what you're going to teach from the gate, we'll still watch
@NeilvsZA
@NeilvsZA 2 жыл бұрын
2 days ago I spent 6 hours trying to figure out why some code wasn't working, only to discover this little catch with the spread operator. I'm sure this video will save developers many hours!
@JamesQQuick
@JamesQQuick 2 жыл бұрын
So glad you think it will be helpful!
@quangnguyencong8728
@quangnguyencong8728 2 жыл бұрын
Could you share the context? I am seeking some real examples for this problem. Happy hacking, bro!
@tyengineer0
@tyengineer0 2 жыл бұрын
Dude love all your vids I’m a full stack dev w/a passion for front-end, and I can tell you that you never stop learning. So watching your stuff is always a good refresher/new point of view on coding I love it keep turning out the content man! All the best 💯
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Thanks so much :)
@dpklabs
@dpklabs 2 жыл бұрын
Another great video - I knew about this, but really enjoyed how you explained it.
@pranavbedre7841
@pranavbedre7841 2 жыл бұрын
which vs code theme do you use??
@NOPerative
@NOPerative 2 жыл бұрын
Pointers in Javascript - good vid. For everyone whom might be unfamiliar with pointers: a reference is a pointer sans confusing jargon. Can't get over the fact that this video is so awesome; excellent discussion.
@ToddDunning
@ToddDunning 2 жыл бұрын
Great job - really cleared me up.
@George-rr1cd
@George-rr1cd 2 жыл бұрын
Learning something new every day great content 👍👍
@BookOfSaints
@BookOfSaints 2 жыл бұрын
I'd love to see deep copying be standardized in the language soon enough
@user-wr8vh6js2i
@user-wr8vh6js2i 2 жыл бұрын
Thank you for your analysis, very detailed。
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Glad you enjoyed it!
@bobkazamakis5169
@bobkazamakis5169 2 жыл бұрын
Really enjoyed that video bro
@toihirhalim
@toihirhalim 2 жыл бұрын
Thanks James
@Sean4Help
@Sean4Help 2 жыл бұрын
This reminds me of dealing with pointers in C++ class when my professor at OIT wanted to make sure we understood pass by reference...he gave us four star pointers to work with as a project. Needless to say, pass by reference is no longer a problem. lol
@plamenavramov2755
@plamenavramov2755 Жыл бұрын
Please can you share what is the settings that you use , its very cool that on the right next to the array when you mark it you can see the result
@tombraider6532
@tombraider6532 2 жыл бұрын
Good tip that makes sense
@oldbig1183
@oldbig1183 2 жыл бұрын
Hi James, I noticed that your vscode showed runtime value at the end of every line, could you please tell me how to do that?
@noopurp123
@noopurp123 2 жыл бұрын
Nice video. Can you also do a video on Symbol and its uses in Javascript? Thanks...
@achtube85
@achtube85 2 жыл бұрын
Yey! I am in for the JS challenges 🦄
@Apprenticer
@Apprenticer 2 жыл бұрын
So I will be the 3rd who asks the same question. What vs theme do you use? So will you answer now?
@betonkoca
@betonkoca 2 жыл бұрын
deep copy - shallow copy if we use the right terms
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Did I not say that?
@skatyan
@skatyan 2 жыл бұрын
Got to know about this the tough way when i just started working as a web developer, i assumed spread op make a true copy and had to deal with a very frustrating debug session 😭
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Yep. I've seen lots of people make this mistake which is why I did the video :)
@gmkhussain
@gmkhussain 2 жыл бұрын
JS is easy for 2 people. One who knows JS actually & other one who just know JS is easy. 😂
@markuscorvus7354
@markuscorvus7354 2 жыл бұрын
if you are javascript developer :D
@reactm
@reactm 2 жыл бұрын
How do you get auto suggestions while writing code in Vscode .
@JamesQQuick
@JamesQQuick 2 жыл бұрын
I just use the built in intellisense. If I'm working in a JavaScript file, it gives the recommendations.
@pakkavideos
@pakkavideos 2 жыл бұрын
Any other ways to clone the multi level objects?? When i use json.parse/stringfy functions inside the objects are missing... Can anyone tell best way to clone?
@subhankanacharjee2135
@subhankanacharjee2135 2 жыл бұрын
Use lodash.
@chhavimanichoubey9437
@chhavimanichoubey9437 2 жыл бұрын
just learnt ... now i know main takeaway about this
@rickharold7884
@rickharold7884 Жыл бұрын
Hmmm good info.
@sparklite1015
@sparklite1015 2 жыл бұрын
I am having a problem in HTML . Image is not showing/loading in Browser (Firefox) when html file is opened. I want image as background. My html file is in folder in D: drive and my image is in F: drive. I am using VS CODE (system setup).
@sparklite1015
@sparklite1015 2 жыл бұрын
Can anyone solve this problem
@sparklite1015
@sparklite1015 2 жыл бұрын
@@user-vl6xf7mp6m Is there any way to use different drives for webspace?
@LeonardoOliveira-ko1rf
@LeonardoOliveira-ko1rf 2 жыл бұрын
I just understood a bug that I faced a few days ago
@saivivekravi6637
@saivivekravi6637 2 жыл бұрын
Which vscode theme are you using I like it can you mention name
@fmdj
@fmdj 2 жыл бұрын
Yeah like it's kinda why it's called a spread operator, not a deep-copy operator. Funny, the thought this behavior could cause issue to someone never crossed my mind.
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Well, I've seen it cause many problems for many people. Hence, the video
@torbenbuck380
@torbenbuck380 2 жыл бұрын
Uh, JS doesn't copy an array if you'd do: names = ['James', 'Jess', 'Lily', 'Sevi']; copyNames = names; ? It's just pointing to 'names'? Or did you just use that to explain how it works?
@kristofferjohansson3768
@kristofferjohansson3768 2 жыл бұрын
You forgot the spread part. Your example is not same as in the video.
@torbenbuck380
@torbenbuck380 2 жыл бұрын
@@kristofferjohansson3768 I think you didn't expand the comment 🤔 I asked if this is isn't copying an array (and pointing to it instead)
@kristofferjohansson3768
@kristofferjohansson3768 2 жыл бұрын
Torrent, I missed your intention. Yes b[]…a[] creates a pointer. Only basic types are copied in JS.
@torbenbuck380
@torbenbuck380 2 жыл бұрын
@@kristofferjohansson3768 I just tried it in a console (I wrote the other comments on a phone). Damn, didn't know that. Weird that I didn't trip over this already. names = ['James', 'Jess', 'Lily', 'Sevi']; copyNames = names; copyNames[0] = 'Billy' copyNames > (4) ["Billy", "Jess", "Lily", "Sevi"] names > (4) ["Billy", "Jess", "Lily", "Sevi"]
@vinayrwt
@vinayrwt 2 жыл бұрын
Great video 🆒
@RaselAhmed-sb5xx
@RaselAhmed-sb5xx 2 жыл бұрын
I love javascript
@GG-uz8us
@GG-uz8us 2 жыл бұрын
Same as with python.
@RoboticsDevelopment
@RoboticsDevelopment 8 ай бұрын
wakka quokka
@anthonywanjala678
@anthonywanjala678 2 жыл бұрын
//THANKS FOR THE VIDEO SIR.. //WHY DOES IT NOT WORK SIR... THE WAY I WANT SIR?..😢😢 var marks={'ENGLISH':'','MATHEMATICS':'','CHEMISTRY':'','BIOLOGY':'','PHYSICS':'','GEOGRAPHY':'','HISTORY':''} function enter(_subjectt, maks){ let makss={...marks, _subjectt:maks} console.log(makss) } enter('ENGLISH','34')
@zloy_ax8496
@zloy_ax8496 2 жыл бұрын
+++
@dvdrtrgn
@dvdrtrgn 2 жыл бұрын
The code hints that keep popping up... it’s just way too much.
@rl6382
@rl6382 10 ай бұрын
Fantastic video
@JamesQQuick
@JamesQQuick 10 ай бұрын
Thank you so much!
ТАМАЕВ vs ВЕНГАЛБИ. Самая Быстрая BMW M5 vs CLS 63
1:15:39
Асхаб Тамаев
Рет қаралды 4,7 МЛН
IS THIS REAL FOOD OR NOT?🤔 PIKACHU AND SONIC CONFUSE THE CAT! 😺🍫
00:41
The Noodle Picture Secret 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 30 МЛН
JS Spread Operator: How It Works & Why I Love It
16:31
Colt Steele
Рет қаралды 75 М.
Tips For Using Async/Await in JavaScript
16:26
James Q Quick
Рет қаралды 394 М.
Why I Don't Use Else When Programming
10:18
Web Dev Simplified
Рет қаралды 1,2 МЛН
Why Is Array/Object Destructuring So Useful And How To Use It
13:24
Web Dev Simplified
Рет қаралды 419 М.
Tips and Tricks for Debugging JavaScript
13:03
James Q Quick
Рет қаралды 405 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
ТАМАЕВ vs ВЕНГАЛБИ. Самая Быстрая BMW M5 vs CLS 63
1:15:39
Асхаб Тамаев
Рет қаралды 4,7 МЛН