Welcome back to JavaScript programming, today we are going to discuss about the variables.
What is a Varible?
Variables are used to store the values in it.We can use those variables in every where we want and can change the value of that variable.
In JavaScript we can define variables in 3 types:
- Using **Var **keyword
- Using letkeyword
- Using constkeyword Now, we took deeper into these types with some examples: 1.Var: It is used to declare variables in javascript that are function-scoped. The var statement is also used to declare global-scope variables.
Note: Before ES6 introduction, all the keywords in JavaScript were declared with the var keyword.
2.let: JavaScript let keyword is used to declare variables that are block-scoped. Variables defined with the let keyword cannot be redeclared in the same scope and must be declared before use.
Note:let keyword was added in the ES6 or ES2015 version of javascript.
3.const:It was also introduced in ES62015(ES6) the const keyword to define a new variable. Variables declared using const keyword cannot be re-assigned.
Note:Variables specified using const cannot be redeclared and have block-scope.
We can discuss more about the scoping in the next lecture.
See you soon...🤠🤠ðŸ¤
Top comments (0)