Тёмный

JavaScript Value vs Reference Types 

Programming with Mosh
Подписаться 4 млн
Просмотров 96 тыс.
50% 1

JavaScript Value vs Reference Types
🔥Get the COMPLETE course (83% OFF - LIMITED TIME ONLY): bit.ly/2M1sp4B
Subscribe for more videos:
/ @programmingwithmosh
Want to learn more from me? Check out my blog and courses:
programmingwithmosh.com
/ programmingwithmosh
/ moshhamedani

Опубликовано:

 

14 май 2018

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 69   
@AriKariG
@AriKariG 5 лет назад
My family is from Hamedan...Love your explanation of this topic really simplified, clean, and straight to the point.
@sodiqayilara1519
@sodiqayilara1519 3 года назад
No matter the amount of articles you have read,Mosh will always teach you something new and useful.Awesome teacher,thanks Mosh.
@lynnqi6451
@lynnqi6451 4 года назад
great explanation, very clear, straight forward. Help me a lot, thank you very much!
@NoahNobody
@NoahNobody 6 лет назад
Wow, I didn't know that. I really need to improve my JS.
@ceddh15
@ceddh15 3 года назад
value vs reference was driving me crazy but this video absolutely helped me. thank you for the explanation
@Navistar-cu2po
@Navistar-cu2po Год назад
Clear, Concise, Straight to the point. Your video helped me grasp the concept quickly.
@han5173
@han5173 4 года назад
very straightforward and easy to understand! thank you!
@EnglishRain
@EnglishRain 4 года назад
FANTSTIC explanation! You're brilliant man! Hit home in first stroke!
@aaabbb-qv4ff
@aaabbb-qv4ff 4 года назад
VERY nice explanation. Simple and to the point. Thank you!
@sdix20
@sdix20 Год назад
Excellent, concise explanation. Thank you, Mosh!
@anyakhardina6174
@anyakhardina6174 3 года назад
Another underlying principle worth mentioning here for the example starting at 3:05 is called "variable shadowing". Because our inner variable's name is the same as the outer variable's, a variable in the inner scope is said to shadow a variable in the outer scope. That is why we cannot re-assign a value assigned to a global variable. However, if you tweak this example a little bit: let number = 10; function increase() { number++; } increase(); console.log(number); So, here we are not passing in any arguments and therefore a value in the global variable can be re-assigned.
@cferracini
@cferracini 3 года назад
THANK YOU SO MUCH!!!! I researched a lot and the answer was right here in the comments! I was testing: *console.log('obj ',increase(obj));* *increase(obj);* and was getting undefined. I couldn't understand why... actually I don't fully understand yet. Because if I change: *function increase(x){ x++; }* *increase(obj);* *console.log('obj ', obj);* -> still gets 10. and *console.log('obj ',increase(obj));* -> still gets undefined is it because when we put "increase(obj);" obj becomes the x inside de function so we get the "variable shadowing" again? also... why do that function at all if it will only be able to deal with that one variable? it is easier to just put *obj++;* then print
@progtom7585
@progtom7585 4 года назад
this is excellent, im reading a "well regarded" book at the moment and its like double dutch compared to this simple explanation... thanks mate.
@nourslimane571
@nourslimane571 2 года назад
this explanation helps with every programming language , also one can learn about this fundamentally with C , great content.
@mariekevandijk4
@mariekevandijk4 2 года назад
Brilliantly explained, thanks!
@DS-zr9gv
@DS-zr9gv 4 года назад
Why are you so awesome at explaining. Please make more on Angular7 and JS
@a_maxed_out_handle_of_30_chars
thank you, simple and to the point :)
@rohitkudalkar92
@rohitkudalkar92 4 года назад
ooohhh, That was a very clear example. Thanks.
@danielakoyleek3757
@danielakoyleek3757 Год назад
Thanks sir. This was hard to get my head around til i watched this.
@abdelkrimeljaouhari2370
@abdelkrimeljaouhari2370 Год назад
you've made it very simple ,thanks.
@ablamohamedamine
@ablamohamedamine 4 года назад
Very useful Tutorial ! Thanks a lot :D
@sakthi3687
@sakthi3687 6 лет назад
Thanks Mosh 👍✌️😊... I am expecting ES6 features video
@ciceroaraujo5183
@ciceroaraujo5183 4 года назад
You are really a great professor
@ahmedabbas8774
@ahmedabbas8774 5 лет назад
love you your videos very good explanation.
@Dj7wiLLY
@Dj7wiLLY 3 месяца назад
explained SOOOOOOOOOOO DAMN WELL !!!!!!!!!!!! Thank you so much, man !!!
@jsprodev2425
@jsprodev2425 6 лет назад
Very helpful. Thumbs up
@11vag
@11vag 4 года назад
So far, the best explanation I´ve seen about this. Thank you mate.
@andTutin
@andTutin Год назад
the thing is. its wrong
@AA-fe1zl
@AA-fe1zl 4 года назад
Excellent video!
@Antarah525
@Antarah525 3 года назад
Thanks, This really helped me
@ZilverDx
@ZilverDx 5 лет назад
Coming from C# to this I wasn't able to reference correctly a variable in JS. Thank You SO MUCH! Now I get it with this video!
@jmcauhy
@jmcauhy 5 лет назад
Brasileiro tá em td lugar kkkk
@daniyahaider6468
@daniyahaider6468 3 года назад
i saw your video it was so interesting I thought it would be boring like other videos of other programers but when I started to see it the 6 mins gone away so fastly that I saw your video again and again and it was so fun can u make a video on symbols es6?
@tanvirmohammedakif5899
@tanvirmohammedakif5899 2 года назад
concept nicely explained, highly appreciated ///
@ajaynathgupta
@ajaynathgupta 6 лет назад
Nice explanation
@s7s_space
@s7s_space 3 года назад
thanks Mosh
@drementer9
@drementer9 Год назад
🔥 awesome content
@behindthescene2727
@behindthescene2727 2 года назад
Thank you sir
@sonamuhialdeen7866
@sonamuhialdeen7866 3 года назад
So good tutorial
@bavan1358
@bavan1358 2 года назад
I almost gave up on this topic , you saved me
@javascript_developer
@javascript_developer 3 года назад
Thank again.
@KayhanEskanndari
@KayhanEskanndari Год назад
best explain ever
@baatar
@baatar 4 года назад
You are great.
@ArgKilljoy
@ArgKilljoy Год назад
Great explanation. I wish you wouldn't have named the parameters the same as the arguments. I would've understood it a bit sooner. Thank you!
@robertjones811
@robertjones811 5 лет назад
Javascript is always pass by value. Pass by reference does not exist in JavaScript. When you remind yourself about the fact that an object and a reference to that object are 2 *independent* things, it will make more sense. I suppose we've been conflating and object "reference" and passing function arguments "by reference." stackoverflow.com/a/13104500/463206 stackoverflow.com/questions/37290747/pass-by-reference-javascript-objects#comment62108759_37290747 When passing a object reference, the *value* of that reference (e.g. the address of the object) is copied and that copy is passed - This is the definition of pass by value. "Pass by reference" means the original reference, not a copy, is passed. Here's the litmus test: In the called function assign a different object to the reference variable. If the original reference now points to this different object then you have pass by reference. But this does not happen in JavaScript. Of course you can change the object's properties, because the reference copy is pointing to the same object. But that is not germane. Rather, "Pass by xxxx" means - whatever you're passing, if it a copy it is "by value", if it is the original it is "by reference".
@ashadcosta8756
@ashadcosta8756 2 года назад
A doubt - when we're consoling the value of x which is supposed to store the reference (address) of the object then why it is printing the object itself? Should not it print the address of the object as it is storing the same?
@PeriklesPeriklesoglu
@PeriklesPeriklesoglu Год назад
thanks
@mohamedprogrammer19
@mohamedprogrammer19 Год назад
im happy cuuuuz i find this video
@LexRexLibertarian
@LexRexLibertarian 3 года назад
Great video but the scope pollution part confused me a bit
@samareshshil69
@samareshshil69 Год назад
great
@rafaelcorrea7959
@rafaelcorrea7959 6 лет назад
How do I force copying an object? (not by reference)
@mel7im19911
@mel7im19911 4 года назад
What about if we define Number/Strings as Objects, ex: let x = new Number (10) let y = x Is it will be assigned by reference or value?
@sagargahatraj5196
@sagargahatraj5196 3 года назад
refrence coz y is coping an object
@hesamdanaey5446
@hesamdanaey5446 3 года назад
reference i think. that is object now
@codeconceptswithmughees
@codeconceptswithmughees Год назад
So much better than my explanation 😅
@mindurownbussines
@mindurownbussines 5 лет назад
in
@francsicozuniga3721
@francsicozuniga3721 Год назад
Can anybody tell me what software or site he is using to demonstrate this? I am new to this and would really benefit from an app or something that lets you practice.
@ZTP1940
@ZTP1940 2 месяца назад
Visual Studio Code
@kayan_dev
@kayan_dev 4 года назад
let scoop is out of function increase
@HassanMalikTW
@HassanMalikTW 6 лет назад
let number = 10; function inc(n) { number = number + n; } inc(5); number; // result is 15 HOW DOES THAT HAPPEN?
@davidsoto8445
@davidsoto8445 5 лет назад
In case some else gets confused by this. see 0:34 of the video. This is by definition pass by reference.
@igu642
@igu642 Год назад
❤❤
@prateek4524
@prateek4524 3 года назад
🔥🔥🔥🔥🔥🔥
@rutumendhe3359
@rutumendhe3359 4 года назад
You should have given numbers for videos 😢😢 it's hard to find which is first and next video ... Content is good but navigation is hard 😢😢
@mehmetedex
@mehmetedex 3 года назад
String is considered as an object and primitive type at the same time how confusing is that 🤣🤣🤣🤣🤣🤣
@Himanshu9178
@Himanshu9178 3 года назад
confused unga bunga
@mek059
@mek059 5 лет назад
Unfortunately I don't understand the concept :(
@andTutin
@andTutin Год назад
wrong
Далее
JavaScript Scope (Local vs Global)
5:43
Просмотров 56 тыс.
JavaScript - Reference vs Primitive Values/ Types
20:56
Reference Vs Value In JavaScript
15:12
Просмотров 179 тыс.
JavaScript Bitwise Operators
9:26
Просмотров 99 тыс.
Java is ALWAYS Pass By Value. Here's Why
5:22
Просмотров 118 тыс.
48: Pass By Reference VS Pass By Value
11:07
Просмотров 4,4 тыс.
Learn JSON in 10 Minutes
12:00
Просмотров 3,1 млн
JavaScript Getters and Setters | Mosh
6:37
Просмотров 236 тыс.
JavaScript this Keyword
8:21
Просмотров 447 тыс.