JavaScript - Reference vs Primitive Values/ Types

preview_player
Показать описание
One of the most common error sources: Not understanding what the difference between reference and primitive values is. This video will clear up the confusion.

Need more JavaScript Training?

Want to become a frontend developer? Consider diving into some of my courses:

See you in the videos!
Рекомендации по теме
Комментарии
Автор

Thanks for concepts about reference vs primitives type and heap/stack too!
3:39 string is primitive (copy by value)
6:47 object, array are references type
7:05 primitives are store on stack
7:35 references are store on heap (take longer to access, store bigger amount of data)
8:40 stack (store like stack 'push on top')
9:16 heap (store pointer)
10:48 it assign a pointer not value
14:50 Object.assign create new object and merge with existing one
16:07 Object.assign doesn't deep clone
17:26 may use Lodash to clone instead
19:04 copy array

nuttaphonr.
Автор

Yeah man, you did a great job at explaining this stuff, I thought I understood it before but now I really understand it. God bless you 100 man. Peace.

josiahtobas
Автор

That stack and heap explanation was very insightful. Thank you!

akshhatsrivastava
Автор

The short version, not 20 minute version of this, is that primitives (things that aren't containers for multiple separate values) make copies when passed to a function; while objects (containers for multiple separate values) make *references* to the object when passed to a function. In other words, when something is likely to be relatively small, it's okay to make a copy, but when it can potentially be enormously large, you just say where the thing is. Remember, primitives = copies && objects = references (which means addresses || pointers).

naythaniel
Автор

Max, you're very good at explaining complex topics in a simple way that makes them easier to understand. Thanks for the video.

spaces
Автор

Thank you for this visual explanation, really made me understand. The pictures of the Stack and Heap sure helped as well ! :)

samirergaibi
Автор

Max, I don't know how you make explaining this so simple. If I would try to transfer what I have learned, I would confuse the hell out of the people listening. Thanks a lot for all the content you provide and for making many complicated subjects look actually, again, simple.

energan
Автор

This is one of the most confusing tutorial i've ever watched.
And I have to watch it again.
And again.
But thank you very much. Well done.

dines
Автор

This is excellent, the addition of the stack and heap explanations really clear this topic up. One of those things that is both easier and harder than it looks...

jimmysignature
Автор

Very good explanation. I remember in C++, for every constructor, you have to have a destructor, otherwise the objects will 'pile up' on the heap = memory leak.

eruston
Автор

Wow Max, I thought I knew what primitive and reference types were. You simply took these concepts to a whole new level! I didn't know about the stack and the heap at all! Thanks for explaining these amazing concepts.

JuanFVasquez
Автор

Awesome video, came here because in your Udemy course about Angular you said we should look this subject up (Primitive values vs Reference values). I think I got the main ideas pretty well, I followed your coding in JSbin myself. Thanks Max !

RaterisimoCBA
Автор

The stack and heap explanation and illustration for these concepts made lightbulbs go off for me. Thank you.

sydneyhill
Автор

This is the best and most concise explanation I have seen on YouTube. Thanks

cdac
Автор

amazing as always. Thank you, Max. Maybe it could be a little bit hard for newbies, but that's the best explanation I saw for about a year of learning JS

ihortsarenko
Автор

I'm impressed by your fluent and well-prepared explaining. your gestures are also very entertaining haha, thanks for doing what you do.

Concentrum
Автор

Brother ! I really respect you. You are the best educator of all time. If you weren't born i couldn't understand these things because there is noone explain these things very specific and easy as you. Thanks

berkan
Автор

That makes sense. thank u.
Earlier I was bit confused why u took long steps to copy in one example of your react course.

naqeeburrahman
Автор

This actually helped me understand how to use pointers and reference values in C++, too!
Thank you Max! :D

tezdogs
Автор

You did the explanation as best as you could. Thanks a lot!

dhanooshbargav