Es6--let and Const commands

Source: Internet
Author: User

1. The difference between let and const:

1) Let can be modified, const is a constant cannot be modified;

2. The difference between Let,const and Var:

1) Let,const There is no variable promotion; So don't worry about pre-interpretation and scope issues;

2) repeated declaration of the same variable is not allowed under the same block-level scope;

3) ES6 allows declaring functions within a block-level scope,

A function declaration is similar to, that is, var promoted to the head of a global scope or function scope,

Also, the function declaration is promoted to the head of the block-level scope where it resides;

4) ES6 in order to maintain compatibility, the var function global variables declared by commands and commands are still properties of global objects, and on the other hand, the let const global variables declared by commands, commands, and class commands are not attributes of global objects. In other words, starting with ES6, the global variable will gradually decouple from the properties of the global object.

Es6--let and Const commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.