16.1: let vs var - Topics of JavaScript/ES6

  Рет қаралды 221,682

The Coding Train

The Coding Train

6 жыл бұрын

In this video, I cover the "let" keyword in ES6 JavaScript. I discuss the differences between "let" and "var" (block scope vs. functional scope).
Video on "const": • 16.2: const - Topics o...
Support this channel on Patreon: / codingtrain
To buy Coding Train merchandise: www.designbyhumans.com/shop/c...
To Support the Processing Foundation: processingfoundation.org/support
Send me your questions and coding challenges!: github.com/CodingTrain/Rainbo...
Contact:
Twitter: / shiffman
The Coding Train website: thecodingtrain.com/
Source Code for the all Video Lessons: github.com/CodingTrain/Rainbo...
p5.js: p5js.org/
Processing: processing.org
For an Intro to Programming using p5.js: • Start learning here!
For Coding Challenges: • Coding Challenges
Help us caption & translate this video!
amara.org/v/dXl2/
📄 Code of Conduct: github.com/CodingTrain/Code-o...

Пікірлер: 352
@pierrem2983
@pierrem2983 6 жыл бұрын
i learned programming & javascript thanks of you Dan because i wanted to do generativ art, now i'm a web developer it's my full time job, thank you :)
@khw9082
@khw9082 4 жыл бұрын
Would you mind telling me how long it took? I am learning as well.
@r_u_p_d9776
@r_u_p_d9776 4 жыл бұрын
@@khw9082 if you practice daily it would take only 1-1.15 months to master JS (only);
@khw9082
@khw9082 4 жыл бұрын
@@r_u_p_d9776 thanks a lot
@r_u_p_d9776
@r_u_p_d9776 4 жыл бұрын
@@khw9082 no problem buddy.
@Bayo106
@Bayo106 4 жыл бұрын
@@khw9082 lol this is not true. Even javascript developers with 5 years experience have not mastered Javascript
@DavidBadilloMusic
@DavidBadilloMusic 5 жыл бұрын
"A variable should have the smallest scope that is needed." I like that.
@crehenge2386
@crehenge2386 6 жыл бұрын
European concortium of mango loving astronauts, sounds reasonable xD
@sck3570
@sck3570 6 жыл бұрын
Lmao
@MarkAhlquist
@MarkAhlquist 3 жыл бұрын
Mangonauts!
@irrelevanceuk
@irrelevanceuk 2 жыл бұрын
😆
@leeloohad
@leeloohad 2 жыл бұрын
When I'm down I watch Coding train videos and the sun shines again :) Thanks for being such an awesome human being and teacher!
@theanthologist9567
@theanthologist9567 5 жыл бұрын
Love your stuff, Dan! You're becoming my go-to resource, whenever I'm confused about a concept. Keep up the good work!
@jackhales6179
@jackhales6179 6 жыл бұрын
This doesn't have to be re-done as you said in the video, this is nice honestly, there are so many boring programming videos on the web that the enthusiasm really helps, similar feelings to CodeCourse :) Keep it up man, 10/10
@goncalopedro9054
@goncalopedro9054 5 жыл бұрын
By playing around with var and let I kind of got the idea of how it worked but once you explained that "hoisting" term, things really got clear and I remembered what my high school programming teacher used to say regarding C++ and Pascal: "If you're going to declare something, do it at the top of the file!". That really clicked in my brain once you explained what hoisting was :D Keep up the good work bro. You're killing it!
@dankang06
@dankang06 6 жыл бұрын
Awesome video -- your breakdown of the differences between var and let was perfect. I love the energy too. Thanks!
@jermainebrayne437
@jermainebrayne437 6 жыл бұрын
this was perfectly explained, love the energy!
@JanneWolterbeek
@JanneWolterbeek 2 жыл бұрын
This is actually very informative AND entertaining/funny. That is unique, not many have this talent. Makes learning much easier for people like me! Thanks!
@nicksmeta
@nicksmeta 3 жыл бұрын
Wow, amazing! Your explanation style is so verbose (in a good sense) that I can just listen to many of the videos, while doing chores and stuff, and understand the ideas being presented. Simply marvelous!
@franksimon8375
@franksimon8375 2 жыл бұрын
Yeah I do that
@VantageVibesWorld
@VantageVibesWorld 6 жыл бұрын
man you are funny and also explaining in good detail at same time. i love this kind of presentation. thank you.
@gagangupta1255
@gagangupta1255 6 жыл бұрын
Awesome video - very clearly defined the diff between var and let !!
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Thank you!
@jojojawjaw
@jojojawjaw 6 жыл бұрын
Crystal clear explanation of the difference, thanks a lot! ♥ I've been using var all my life (more like for the few months ago), thinking that the variable is limited to its block like C++ and Java, after watching this, I was like what!
@mattgraves3709
@mattgraves3709 5 жыл бұрын
Exactly the same issue I have with scope, I learned how to program with Java and think in the same fashion. You are a great teacher! Thank you
@roltthehunter
@roltthehunter 6 жыл бұрын
Great video, i just started coding, in JS coming from a background in C++, and and i mostly learned to code JS from mini bootcamp that used ES6 and now i am going back and doing intro courses, and a lot of them use var and stuff and write in in concatenated strings over just using a template string, i much prefer the ES6 stuff and i am glad i learned it first.
@bearded-cat
@bearded-cat 6 жыл бұрын
I am learning JS on free code camp now and you explain things so well its surprising easy for me to fill out challenges. thanks a lot and please keep making more videos! its a shame that i havent found your channel earlier
@ciwanye2291
@ciwanye2291 5 жыл бұрын
This guy made me love programming through his lessons thanks man !
@joshua_tobler
@joshua_tobler 4 жыл бұрын
That was actually super helpful. I'm graduating from Google Apps Script to real Javascript and doing some game and graphics coding for the first time, and this explained > 25% of the language barrier I was encountering.
@thechenoutdoors3050
@thechenoutdoors3050 5 жыл бұрын
best video out there explaining let vs. var!
@theantibeta
@theantibeta 6 жыл бұрын
ECMAScript === European Computer Manufacturers Association Script
@BloodyScythe666
@BloodyScythe666 6 жыл бұрын
I think that'd be single equal since triple equal will compare those two and will return false :P
@theantibeta
@theantibeta 6 жыл бұрын
Right, but, did you see that decorator '
@BloodyScythe666
@BloodyScythe666 6 жыл бұрын
Fair enough!
@hishammubarak3421
@hishammubarak3421 6 жыл бұрын
Thank you
@sharank
@sharank 6 жыл бұрын
I dont know. It looks like dickbutt to me
@nikeethamusic330
@nikeethamusic330 4 жыл бұрын
Love the way you simply even the most complex topics!!
@sowmyavijayakumar9766
@sowmyavijayakumar9766 6 жыл бұрын
Wow..this is excellent stuff..i have been wracking my head over let vs var for a while and I finally get it!
@vivekraj9875
@vivekraj9875 4 жыл бұрын
Happy teachers day Dan,😘😘,,, You're the best teacher I've ever seen... And You're attitude towards teaching is just Awesome 😀😀
@JackFlashTech
@JackFlashTech 4 жыл бұрын
This is really interesting. I had thought that it was some kind of optimization around declaring constants and variables that could change as functional programming became more fashionable. Thanks.
@mrshurukan
@mrshurukan 6 жыл бұрын
Awesome video! Thanks, now I'll use "let" as well, because I'm used to think about "block scope" and not "function". Very interesting stuff, thanks a lot!
@ga7853
@ga7853 5 жыл бұрын
You are magnificent, and the way you made your videos is unbelievable fantastic, I have not seen anyone pro or regular who made such good videos that are pleasant to watch like you did, like if I'm sitting in a great school, Thank you a million for your great way of explaining and for those wonderful great videos that made learning fun.
@tyfooods
@tyfooods 5 жыл бұрын
I reaaaaaallly like your videos and teaching style. Keep on keeping on!
@MegaARYARAJ
@MegaARYARAJ 5 жыл бұрын
Interesting JavaScript tutorial..this is the best video I got till now about the differences between var and let..
@Evuce1000
@Evuce1000 5 жыл бұрын
Not boring at all! Love your lessons!
@lleytonmorris6305
@lleytonmorris6305 6 жыл бұрын
thank you so so much. you started using let a while back and I asked my qualified friend to explain why and it didn't make sense other than they had different use cases... der. after listening to this video it makes absolute sense and i will 100% be using let for, at least, my for loops. your videos are my biggest inspiration and I am just so glad that through whatever round about way, you are able to explain to me at least how all these abstract things work.
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Thank you!
@sharpfocus9572
@sharpfocus9572 3 жыл бұрын
Hoisting and Nested loops is an nightmare for many people I think , you are an excellent teacher , your way of learning us is fantastic , the class table's explanation is the key to success , many greetings my friend !!
@heksqer1022
@heksqer1022 5 жыл бұрын
This was a great video !! This had me confused for a loooong time !
@ky-effect2717
@ky-effect2717 3 жыл бұрын
Thank you! This is exactly what I was looking for and very well explained.
@WistrelChianti
@WistrelChianti Жыл бұрын
Thanks so much for this. I had been wondering and had been meaning to find out at some point but your examples were superb to effectively demonstrate the difference. Amusingly I'd never realised that "for (int i = etc" in C++ only had i in scope inside the loop. I mean it makes sense but I was never consciously aware of it. I guess I rarely tried to re-use the counter outside of the loop, or if I did, I guess I must have fixed it on auto-pilot without really thinking about it properly.
@jorge88824
@jorge88824 4 жыл бұрын
The first time I've watched a video from this channel I was thinking "what is wrong with that guy?". After the ending of the first video I've realized how good Dan's explanations are. Since then I'm following his videos and enjoying the way of braking difficult concepts into small pieces. I've learned a lot about JS and found answers of a lot of questions I've asked myself. Keep going, man! 10x for creating this amazing channel and being a person you are! Greetings from Bonn, Germany.
@bunderland
@bunderland 4 жыл бұрын
There is nothing wrong with him :) He has a great personality.
@luismuzquiz1400
@luismuzquiz1400 6 жыл бұрын
Very entertaining explanation. Thanks!
@MrFLAWl355
@MrFLAWl355 6 жыл бұрын
YES! promises and promises chaining PLEASE!
@martin-xq7te
@martin-xq7te 5 жыл бұрын
Very well explained. I am starting out with Javascript so a good piece of timing for me. Ive also looked at your video on Genetic Algorithms in P5.js. If viewers have not seen that its well worth a look. If you have a pdf of that video I would buy it. Keep up the good work
@hassanshahzad3922
@hassanshahzad3922 3 жыл бұрын
He is the one of the best presenter i have seen in my life.
@rdscleaners
@rdscleaners 9 ай бұрын
Love your videos and explanations of topics so everyone can understand :)
@ritikkhatri
@ritikkhatri 6 жыл бұрын
That was a very nice explanation!!
@emmakent3681
@emmakent3681 Жыл бұрын
Awesome, thank you! Best explanation for this that i've read/watched. Sidenote: when i was running the example where 100 was expected, i was getting undefined. I needed to run setup() after, so that part stumped me for a bit. function setup() { for (var i = 0; i < 100; i++); } console.log(i); } setup() // ;)
@Messirobben047
@Messirobben047 6 жыл бұрын
I wish all the teachers in colleges were like you. Amazing Skill.
@Zen-lz1hc
@Zen-lz1hc Жыл бұрын
This was one of the most entartaining video that I watched on `let` and `var` pretty fun, thank you :)
@UnknownUnknown-tx1jc
@UnknownUnknown-tx1jc 5 жыл бұрын
Great tutorial. It really helps when I don't feel like reading documentary. oh I guess why they didn't think about modifying the var to be block scope is because many websites still uses var. If they would have change it some websites, would have been broken and you could imagine the problems that would stur up. By the way block scope is really cool
@footballarena6562
@footballarena6562 4 жыл бұрын
i started learning python but stopped to learn js because of this channel. I love the way you teach and your contents.
@tobiumevolume9890
@tobiumevolume9890 6 жыл бұрын
Amazing video, would have saved me thousands of lines of code if i had informed myself about let before ^^
@tobiumevolume9890
@tobiumevolume9890 6 жыл бұрын
Yaay, i got a heart :D
@BloodyScythe666
@BloodyScythe666 6 жыл бұрын
thank you for the explanation. wondered for quite some time now what's the actual difference and why to use it instead of var. you could have probably put the const explanation inside this video. 12 minutes isn't too long and it would be all in one place. other than that, great video, dan!
@rrutter81
@rrutter81 4 жыл бұрын
You present in a very entertaining way. One thing you missed was lexical scope with let vs var. Think setInterval method. I tripped up an interviewer on this when they were looking for a closure answer. subscribed
@TheCodingTrain
@TheCodingTrain 4 жыл бұрын
Thanks for the feedback!
@Karlponken
@Karlponken 5 жыл бұрын
Great explanation! Thanks for this video!
@sandeepvk
@sandeepvk 6 жыл бұрын
I don't use JS anymore but I am subscribed because you are so much fun to watch
@justgaming3794
@justgaming3794 5 жыл бұрын
Love your stuff Daniel
@julians.2597
@julians.2597 2 жыл бұрын
"let" is a keyword frequently seen in functional programming languages, which JS is slowly inching closer to becoming at least a language that allows for fully functional code.
@orki974
@orki974 4 жыл бұрын
This it, "function scope", that's the root of the evil I feel about JS, that's why I feel so bad about it. It's also the main reason why I generally don't understand where a value comes from when I read JS : thank you very very much. I'm a C++/Clojure/Rust etc programmer and this is a major difference between JS and other languages in the world that distinguish JS! I completely understand why you prefer "block scope": you're a sane person, and I like that
@stifflery
@stifflery 5 жыл бұрын
over 9000 blessings to you sir for explaining this.
@SpencerDavis2000
@SpencerDavis2000 4 жыл бұрын
great video. I didn't even know what block scope or function scope was, just knew it was different and tricky. Now I know. thank you so much. Subscribed! looking forward to more of your videos :-)
@playerthree5742
@playerthree5742 6 жыл бұрын
Great example! sometimes errors can be good news as well !
@iq0578
@iq0578 3 жыл бұрын
I have always used let, but I didn't know why until now :)
@LawZist
@LawZist 6 жыл бұрын
exactly what i was looking for . now i know the differences
@HarshTalpada
@HarshTalpada 6 жыл бұрын
Daniel, you are always off track. But that is the best part of your way of teaching. Getting off track is indeed necessary for making learning an easy task. Get off track as often as you can, and people will still love you. I just wished you were here in Melbourne. Would have definitely learned all this from you in person.
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
would love to visit Australia someday, have never been!
@Sleepytj007
@Sleepytj007 3 жыл бұрын
Thank You for sharing your knowledge.
@ades3967
@ades3967 4 жыл бұрын
Fantastic explanation of Hoisting in JavaScript!
@darkthrongrising5470
@darkthrongrising5470 6 жыл бұрын
This is actually really good to know.
@kaunjovi8350
@kaunjovi8350 3 жыл бұрын
Does hoisting happen in case of let also? Or any similar transpiling on let keyword before the interpreter can actually work on the instructions?
@bearded-cat
@bearded-cat 6 жыл бұрын
wow thats so well explained! thanks a lot you have new subscriber now
@thecowbox
@thecowbox 6 жыл бұрын
Daniel shiffman: Legend. I tell everyone this.
@mahyarazad
@mahyarazad 3 жыл бұрын
Man, I love your style. It's heuristic 😎😃
@vishnuumakanthan9583
@vishnuumakanthan9583 5 жыл бұрын
Very informative video , Thanks a Lot!
@leonardgarthbrooks
@leonardgarthbrooks 4 жыл бұрын
This might sound like an odd question, but why can't I find this playlist on the Coding Train main KZbin site? In fact, there are a few tutorial series that I can't seem to directly, including the p5 Sound one. Am I missing something?
@rayanfernandes2631
@rayanfernandes2631 4 жыл бұрын
thank you dan.... you opened my eyes.... i googled about this and all it shows is both are seemigly the same .... u can use anything... also in p5js there the var declared in setup() cannot be reffered or used in draw()
@keen123
@keen123 6 жыл бұрын
Very helpful! Thanks Dan!
@Loppy2345
@Loppy2345 6 жыл бұрын
This video is a gem.
@joushwashahzad2341
@joushwashahzad2341 4 жыл бұрын
Best Explanation ever on Let
@StrangeComments
@StrangeComments 6 жыл бұрын
You explained this very well
@sumer9999
@sumer9999 5 жыл бұрын
You are awesome , so are your videos
@AmirAli-kj5bm
@AmirAli-kj5bm 4 жыл бұрын
thanks, really helps me a lot
@thehumbledprogrammer8833
@thehumbledprogrammer8833 6 жыл бұрын
nice video sir! you made my understanding clear!
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Glad to hear!
@aymanafzal
@aymanafzal 5 жыл бұрын
A new subscriber... Great explanation
@alialrahem9817
@alialrahem9817 4 жыл бұрын
Very clear thank you for the video
@maremmaladra292
@maremmaladra292 3 жыл бұрын
Great work, you are the best: keep It on!
@cheeeeeeeeezer151
@cheeeeeeeeezer151 3 жыл бұрын
Thanks!
@dearnobitaa
@dearnobitaa 5 жыл бұрын
European Computer Manufacturers Association (ECMA).
@cm_dev
@cm_dev 2 жыл бұрын
This video was fantastic.
@eandresrodriguez
@eandresrodriguez 5 жыл бұрын
Best teacher ever!
@boozer69n
@boozer69n 6 жыл бұрын
Great explanation, thanks for the video. =)
@Engineer9736
@Engineer9736 5 жыл бұрын
Very informative video. Browsers should communicate this to the developers via the console. “Var is deprecated blabla please use let” or so.
@chang112x
@chang112x 5 жыл бұрын
thx. Finally someone explained to me.
@vishverma9899968908
@vishverma9899968908 5 жыл бұрын
Awesome video, although was laughing throughout the video, but understood the concept clearly. Thanks
@TheNewGreenIsBlue
@TheNewGreenIsBlue 2 жыл бұрын
let was likely used because it's often used as a keyword in functional programming keywords for a long time. It's also used in mathematics to assign values to algebraic values. In terms of linguistics, you're asking the compiler to "please *LET* x *equal* [value]".
@zemalex89
@zemalex89 4 жыл бұрын
Great video!
@sergiyrudenko905
@sergiyrudenko905 5 жыл бұрын
Great video!!! Thanks a lot!!!
@martin_orue
@martin_orue 4 жыл бұрын
Excellent! Thank you!
@Kafka8233
@Kafka8233 3 жыл бұрын
So finally I understand the difference between let and var
@dertyp6833
@dertyp6833 6 жыл бұрын
2:54 - 3:00 Aaaaaaaaaargh!
@evhwolfgang2003
@evhwolfgang2003 6 жыл бұрын
So with let and var, the variable is typeless or dynamically typed?
@vincesanchez7790
@vincesanchez7790 4 жыл бұрын
Let is useful :) Thanks man Now i get it
@gabrielscoville1548
@gabrielscoville1548 5 жыл бұрын
"I'm soooo behinddd BTW" lol. thanks for the video though, very informative.
@nurharizulaimanmatharith4023
@nurharizulaimanmatharith4023 4 жыл бұрын
Nice explaination
@mournmey2606
@mournmey2606 5 жыл бұрын
You are very interesting tutorial
@petrospetrosyan1414
@petrospetrosyan1414 4 жыл бұрын
What's the difference between using “let” and “var”?
16.2: const - Topics of JavaScript/ES6
7:42
The Coding Train
Рет қаралды 74 М.
16.3: ES6 Arrow Function - Topics of JavaScript/ES6
22:32
The Coding Train
Рет қаралды 271 М.
ELE QUEBROU A TAÇA DE FUTEBOL
00:45
Matheus Kriwat
Рет қаралды 18 МЛН
it takes two to tango 💃🏻🕺🏻
00:18
Zach King
Рет қаралды 29 МЛН
Omega Boy Past 3 #funny #viral #comedy
00:22
CRAZY GREAPA
Рет қаралды 29 МЛН
格斗裁判暴力执法!#fighting #shorts
00:15
武林之巅
Рет қаралды 85 МЛН
16.7: Array Functions: reduce() - Topics of JavaScript/ES6
14:40
The Coding Train
Рет қаралды 132 М.
16.6: Array Functions: map() and fill() - Topics of JavaScript/ES6
14:26
The Coding Train
Рет қаралды 113 М.
Coding Challenge 180: Falling Sand
23:00
The Coding Train
Рет қаралды 734 М.
Differences Between Var, Let, and Const
8:37
Web Dev Simplified
Рет қаралды 179 М.
16.17: Inheritance in JavaScript - Topics of JavaScript/ES6
17:47
The Coding Train
Рет қаралды 78 М.
STOP Using Classes In JavaScript | Prime Reacts
14:02
ThePrimeTime
Рет қаралды 216 М.
9.19: Prototypes in Javascript - p5.js Tutorial
19:24
The Coding Train
Рет қаралды 257 М.
Is C# Better than Java?
18:41
Gavin Lon
Рет қаралды 11 М.
JavaScript Pro Tips - Code This, NOT That
12:37
Fireship
Рет қаралды 2,5 МЛН
ELE QUEBROU A TAÇA DE FUTEBOL
00:45
Matheus Kriwat
Рет қаралды 18 МЛН