Very detailed perfect lessons you have on your channel! I wish I found your channel earlier because not so many people explain basic foundational things so well. Good work :)
Thanks, Dave !! This one came via a link from my lecturer, but I have worked thru a number of your multi-hour videos previously. Your explanations have helped me to understand many of the core concepts of JavaScript programming and web development.
Ive been having trouble with scope for the absolute LONGEST, everything else in javascript has made sense except that. The second example at 9:50 was spot on.
Мне очень жаль, что мало понимаю английский язык. Но я все равно понимаю эти уроки потому что вы объясняете очень хорошо и детально огромная вам благодарность
Comment made after watching a useful video so I don't forget what it was about #2. Global scope -> Variable accesible through all the code and they are outside any function Block scope -> Variable inside curly braces (as things in for) Function Scope -> Variable inside a function The last two cannot be accessed outside the declared place, for function, it'll return undefined, for block scope, it'll have an error
Hi Dave, thanks for the teaching. I've got a question, when I enter ${x}; in the console it shows ${x} instead of the value. May I know if there is anyway to solve this? Thanks
${x} will cause an error if that's all you type in the console. Unexpected token. Not sure why you would do that? If you have defined x as a variable, just type x.
Var doesn't respect { } scope indeed! Thanks for pointing this out. And thanks for explaining that the notorious "block scope" simply means things like: if { } or for { } etc.
@@damo190 no, modules have scope. Functions can be within a module, too. Their scope would be inside (aka nested) the module. If you understand the scope discussion of this tutorial, it is all you need as a beginner 💯
let a = {f(){console.log(this);}}; Here, the value of 'this' depends from where the function f is called, not from where f is defined. So, I doubt 'this' is in dynamic scope. But I have already learned, JavaScript only supports lexical(static) scoping. That's why I am confused. Please help me.
In your example, "this" refers to the object you are creating. You will see this more clearly if you add a 2nd property like num: 10 or similar and then call the f method on the object a like: a.f() ..it will log the full object to the console. The "this" keyword can make things confusing in JS until you work with it for awhile.
Very detailed perfect lessons you have on your channel! I wish I found your channel earlier because not so many people explain basic foundational things so well. Good work :)
Thank you for the kind words, Alexander!
The best explanation of scope I have seen so far.
It could have avoided me all those "undefined" errors a few weeks ago.
Very good.
Glad it helped! 💯
Wow! What a thorough explanation. Amazing Dave; by far the best on RUclips.
Thank you, Faraz! 🙏🙏
Sometimes, all you need is a video and it does the work of a whole pdf. Thanks man.
You're welcome!
Thanks, Dave !!
This one came via a link from my lecturer, but I have worked thru a number of your multi-hour videos previously. Your explanations have helped me to understand many of the core concepts of JavaScript programming and web development.
Ive been having trouble with scope for the absolute LONGEST, everything else in javascript has made sense except that. The second example at 9:50 was spot on.
Glad to hear this helped!
Thanks Dave! Been looking at several videos on scopes by far the best.
You're welcome! 💯
Roadmap redirected me to your channel, what a tutorial!
Can't recommend enough your channel, well thought explanations, concise, thanks a lot for sharing
Much appreciated!
Very understandable thanks a lot I liked your video thanks for creating this videos
Amazing explanation. Great work Dave. Thank you.
You're welcome 🙂🙏
this is the best explanation on scope I have ever seen 🎉
Thank you!
Wonderfully compiled and delivered. Thanks for giving such crystal clarity in these fundamentals..
You're most welcome
This is so detailed and easy to understand.Thank you
You're welcome!
thank you so much, your clear explanation made me understand the difference between var , let and cons. :)
Thank you for explaining the concept of variable leaking ! Never knew this happens with var
Happy to help! 💯
Your videos are amazing !!!
Glad you like them! 💯🚀
It might be considered as not the easiest topic but with your explanation it's clear! Thank you!
You're very welcome!
Thanks, Dave!
Thank you, Dave! At 10:45 you marked three words "global" which are on seperate lines, and changed them simultaneously. How did you do that?
Highlight one of them and press Ctrl+D to select another. This is with VS Code on Windows.
Great explanation!
Glad it was helpful! 🚀
This guy is the god of JS
Great explanation, thank you!!!
You're welcome!
wow, loved it
Great explaination
Thank you!
Dang...I thought I knew this stuff...lol...good content...I learned a lot
Thanks!
Мне очень жаль, что мало понимаю английский язык. Но я все равно понимаю эти уроки потому что вы объясняете очень хорошо и детально огромная вам благодарность
Thank you for the kind words!
Comment made after watching a useful video so I don't forget what it was about #2.
Global scope -> Variable accesible through all the code and they are outside any function
Block scope -> Variable inside curly braces (as things in for)
Function Scope -> Variable inside a function
The last two cannot be accessed outside the declared place, for function, it'll return undefined, for block scope, it'll have an error
Hi Dave, thanks for the teaching.
I've got a question, when I enter ${x}; in the console it shows ${x} instead of the value.
May I know if there is anyway to solve this? Thanks
${x} will cause an error if that's all you type in the console. Unexpected token. Not sure why you would do that? If you have defined x as a variable, just type x.
Hi! I've had a similar issue recently and it was caused by using quotes (no matter singular or double '/") instead of backticks ``.
Thanks I am now clear
Happy to help!
Var doesn't respect { } scope indeed! Thanks for pointing this out. And thanks for explaining that the notorious "block scope" simply means things like: if { } or for { } etc.
You're welcome! 🙏
Sir, there is also a module scope. I saw in dmitripavlutin article that module scope can also be nested. How can I able to nest a module scope?
You import modules. They do have their own scope. This should be covered in a future lesson. 💯
@@DaveGrayTeachesCode so, importing a module is called module scope nesting?
@@damo190 no, modules have scope. Functions can be within a module, too. Their scope would be inside (aka nested) the module. If you understand the scope discussion of this tutorial, it is all you need as a beginner 💯
Perfect
let a = {f(){console.log(this);}};
Here, the value of 'this' depends from where the function f is called, not from where f is defined. So, I doubt 'this' is in dynamic scope. But I have already learned, JavaScript only supports lexical(static) scoping. That's why I am confused. Please help me.
In your example, "this" refers to the object you are creating. You will see this more clearly if you add a 2nd property like num: 10 or similar and then call the f method on the object a like: a.f() ..it will log the full object to the console. The "this" keyword can make things confusing in JS until you work with it for awhile.
@@DaveGrayTeachesCode so, this keyword is in which scope, lexical or dynamic?
Holy shit a youtube tutorial with a good microphone
Never underestimate the basics...
💯 Right!
Awesome tutorial..Thanks a bunch!