In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of whether let is es6 grammar, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this grammar article of let is not es6. Let's take a look at it.
Let is the syntax of es6. Let is a new keyword in es6, used to declare variables, the declared variables are only valid in the code block where the let command is located, the let command changes the syntax behavior, and the variables it declares must be used after declaration, otherwise an error will be reported and the syntax is "let name=value;".
This tutorial operating environment: windows10 system, ECMAScript version 6. 0, Dell G3 computer.
Is let the syntax of es6?
ES6 added the let command to declare variables. Its usage is similar to var, but the variables declared are valid only within the block of code where the let command is located.
Variables declared by let are valid only within the block of code where the let command is located.
1. There is no variable promotion:
The let command changes the syntax behavior, and the variables it declares must be used after the declaration, otherwise an error is reported.
two。 Temporary dead zone:
ES6 makes it clear that if there are let and const commands in the block, the variables declared by the block form a closed scope from the beginning. If you use these variables before you declare them, you will report an error.
In short, within the code block, the variable is not available until the let command is used to declare it. Grammatically, this is called a "temporary dead zone" (temporal dead zone, referred to as TDZ).
3. Repeated declarations are not allowed:
Let does not allow repeating declaration of the same variable within the same scope. Therefore, you cannot redeclare parameters within a function.
Examples are as follows:
Basic usage:
{let a = 0; a / / 0} a / / error ReferenceError: an is not defined
Valid within the code block
Let is valid within the code block, and var is valid at the global scope:
{let a = 0; var b = 1;} a / / ReferenceError: an is not definedb / / 1
This is the end of the article on "is let the grammar of es6?" Thank you for reading! I believe you all have a certain understanding of "let is not the grammar of es6". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.