Each programming language has rules to store data in memory for operating on that data. Now, the memory location has some name to store and access this data, called "Variable".
Variables defined with let
- It cannot be Redeclared.
- Must be Declared before use.
- It has a block Scope.
But the difference between them is that var- Function scoped and let-Block scoped. Variables are declared with the var keyword, and the values are available throughout the function.
A variable name should have a clean and meaningful word to describe the data it stores. In programming, Variable naming is one of the most complex and important skills. Most of the time is spent modifying and extending an existing code in real time without writing something completely from scratch. When the variables have good names, finding information is much easier. Before declaring it, please consider the right name for a variable.
- Use human-readable names like userName or shopping cart.
- Avoid short names or abbreviations like a, b, and c.
- Make names maximally descriptive and concise. Bad names declarations are data and value. Such names say nothing about the variable.
Preview of the output that you will get on running this code from your IDE.
Follow the steps carefully to get the output easily.
- Download and Install VS Code on your Desktop.
- Open the new file and save as filename.js
- Run the code using (ctr+alt+N) Run button.
I hope you found this useful. I have added version information in the following sections.
I tested this solution in the following versions. Be mindful of changes when working with other versions.
- The solution is created in VS Code 1.73.1 version.
- Code Runner v0.11.8