In ES6, there are three ways to declare variables: , , and .
The var keyword is used to declare variables that have either global scope or function scope. Regardless of block scope, variables declared with var are accessible throughout the entire function. For example:
The let keyword, introduced in ES6, allows you to declare variables that are scoped to the block, statement, or expression in which they are used. This means that variables declared with let are only accessible within the specific block. For example:
On the other hand, variables declared with the const keyword are immutable, meaning they cannot be reassigned once they are defined. For instance: