![]() |
VOOZH | about |
Variables are a fundamental part of many programming languages, and are among the first and most important concepts for novice coders to learn. There are a number of different properties of variables in JavaScript, as well as several rules which must be followed when naming them. In JavaScript, there are three keywords used to declare a variable โ var, let, and const โ and each one affects how the code will interpret the variable differently.
This tutorial will cover what variables are, how to declare and name them, and also take a closer look at the difference between var, let, and const. We will also review the effects of hoisting and the significance of global and local scope to a variableโs behavior.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
JavaScript is a high-level, object-based, dynamic scripting language popular as a tool for making webpages interactive.
Browse Series: 37 tutorials
Software engineer and open source creator
Former Technical Writer at DigitalOcean. Focused on SysAdmin topics including Debian 11, Ubuntu 22.04, Ubuntu 20.04, Databases, SQL and PostgreSQL.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
will you be so kind, to add any additional articles and tutorials, please)
It is not easy at all to use it
Hi Tania, Mark. Thanks for the post. One small typo in the hoisting section; You say โThis behavior can cause issues, though, because the programmer who wrote this code likely expects the output of x to be true, when it is instead undefined.โ but I think you mean โThis behavior can cause issues, though, because the programmer who wrote this code likely expects the output of x to be 100, when it is instead undefined.โ
WOAH, amazing tutorial!
Nice article, but i think you should add in this article the โtemporal dead zoneโ for const and let declarations. Cheers
Wow! Thanks, I got something new to learn. I found good post on this topic which is http://www.visionfortech.com/2018/08/let-vs-var-in-javascript.html So i thought let me share that post with all of you it is well written and well explained by its author.
Thatโs a very thorough article. I was inspired to write this: https://fullstackgeek.blogspot.com/2019/01/variables-scope-in-javascript.html
This was a great resource Thanks for the manager of this site good lunch
Thanks so much, well done! Running the code is what drives home the learning for meโฆ
All declarations (function, var, let, const and class) are hoisted in JavaScript, while the var declarations are initialized with undefined , but let and const declarations remain uninitialized.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.