In JavaScript, there are different ways to declare a variable. These include using the keywords var, let, and const. Each of these has slightly dif...
For further actions, you may consider blocking this person and/or reporting abuse
I expected to eye-roll at yet another in a million "what is var/let/const" type blog posts. But this one was well done, and more balanced than most.
Kyle, thank you so much for the feedback. And please don't forget to share.
This is incorrect. Simply declaring a function with var doesn't make it global at all. If you are in a function, a method or a module then you won't have access to that variable globally.
Do you know what a global scope variable or function is?
It is any variable or function that can be accessed from any part of your code. But in this article, I'd like you to pay attention to the scope that each of the forms offers.
Yes and you are incorrect. Simply using var doesn't make your variable globally scoped. Feel free to share code that shows a var being declared in a function being accessible in the global scope.
I completely agree.
Doing this:
displays an undefined error an thus makes this statement incorrect:
Variables declared with const keyword are not immutable. You only cannot reassign the const variable, but you can modify fields of the object which this variable contains