How to write Javascript Variable ES6 Variable

preview_player
Показать описание
In JavaScript, there are two types of variables that you can declare: ES5 variables and ES6 variables.

ES5 variables are declared using the var keyword. These variables have function scope or global scope, depending on where they are declared. They can be reassigned and redeclared within their scope.

ES6 variables, on the other hand, can be declared using the let or const keyword. let and const are block-scoped, meaning that they are only accessible within the block in which they are declared. let can be reassigned within its scope, while const cannot be reassigned. Both let and const cannot be redeclared within the same scope.

Here's an example of how you can declare ES5 and ES6 variables:
// ES5 variable
var message = "Hello, world!";

// ES6 variables
let name = "John";
const PI = 3.14;

In this example, the message is an ES5 variable, while the name and PI are ES6 variables. Note that ES5 variables can be reassigned and redeclared within their scope, while ES6 variables have different behavior based on their type.
Рекомендации по теме
welcome to shbcf.ru