An Interest In:
Web News this Week
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
May 17, 2021 05:46 pm GMT
Original Link: https://dev.to/sanskrati01/variables-in-javascript-382b
Variables in JavaScript
JS variables are used to store data values. But unlike any other language, the datatypes of that variable are not declared first like in C++. JavaScript has dynamic types. This means that the same variable can be used to hold different data types,
- var, let, and const:
To declare variables we use var, let, and const.
var and let are very similar except in block scope which is discussed in the difference between var and let.
cont is the same as let but used only for constants.
- Difference Between var and let:The main difference between var and let is that scope of var is global while that of let is limited to block. This means if I declare a variable using var, it can be excessed anywhere except in the case of a function. This can be a problem if we use it in loops for example.
- Properties of const :People usually misunderstood the cont. It does not define a constant value. It defines a constant reference to a value, which means we can actually change the properties of a constant object or the element of a constant array. It is just you can reassign a value.
Original Link: https://dev.to/sanskrati01/variables-in-javascript-382b
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To