In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "there is no block-level scope in es6 grammar". The explanation in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "es6 grammar has block-level scope".
Es6 syntax has block-level scope, and the scope formed by a pair of curly braces is block-level scope. Es6 refers to the block-level scope and allows functions to be declared in the block-level scope; function declaration statements behave like let and cannot be referenced outside the block-level scope.
This tutorial operating environment: windows10 system, ECMAScript version 6. 0, Dell G3 computer.
Does es6 syntax have block-level scope?
Es6 syntax has block-level scope
The scope formed by a pair of curly braces is at the block level.
ES6 introduces block-level scopes, which explicitly allow functions to be declared in block-level scopes. ES6 states that function declaration statements behave like let in a block-level scope and cannot be referenced outside the block-level scope.
Before ES6, JavaScript has no block scope, and all variables are declared by the var keyword, that is, variables in the control statement can also be accessed in the external scope.
With the advent of ES6, JavaScript brings us let and const keywords, which also gives it the concept of block-level scope ({} internal is block-level scope, you can use {} to create a block-level scope when testing a small demo to avoid variable name conflicts). Variables defined by let and const in our control statements are not accessible externally. If a variable with the same name is not defined in the global scope, the corresponding error is reported:
Usefulness: block scopes can play a role when you need some temporary variables. By creating block-level scopes, we don't have to worry about messing up global variables defined by others, and we can define our own variables according to our own ideas.
Thank you for your reading, the above is the content of "does es6 grammar have block-level scope". After the study of this article, I believe you have a deeper understanding of the question of whether es6 grammar has block-level scope, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.