Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basics of ES6

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you the relevant knowledge points about the basic knowledge of ES6. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

I. the relationship between ECMAScript and JavaScript

Netscape, the creator of JavaScript, decided to submit JavaScript to the standardization body ECMA, hoping that the language would become an international standard, but JavaScript itself has been registered as a trademark by Netscape, and the subsequent standards are developed by ECMA, named ECMAScript.

Then this version of ES6 introduces a lot of new content, usually referring to the next version of the JavaScript language.

II. Let command

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.

Var and let define the difference between variables:

/ / the scope of var is at the function level (variables defined within the function can only be used in the function) / / function showName () / {/ / var myName = "Jacky Cheung"; / / alert (myName + "Welcome!"); / / the myName here is "Zhang Xueyou" / /} / / showName () / / alert (myName + "Welcome!"); / / an error will be reported here. MyName can only use / / var in the showName function. The scope of / / var is functional (variables defined in the code block can be used outside the code block) / / if (1 welcome 1) / / {/ / var myName = "Jacky Cheung" / /} / / alert (myName + "Welcome!"); / / the scope in which / / let can be run here is at the code block level / / if (1welcome 1) / / {/ / let myName = "Jacky Cheung"; / /} / / alert (myName + "Welcome!") / / error is reported here / / let does not exist variable promotion / / console.log (a); / / error / / let a = "apple"; / / console.log (b); / / undefined / / var b = "banana"

The difference between var and let in loop counting:

/ / for (var I = 1bot I)

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report