The pits used by the let, const, and arrow functions of the ES6 series

  1. variable hoisting
  2. The Importance of Block Scoping
  3. Arrow function this points to
  4. rest parameters and arguments

1. The relationship between ECMAScript and Js

 2. Babel Transcoder

Babel is a widely used ES6 transcoder that converts ES6 code to ES5 code to be executed in older browsers. This means that you can write programs in the ES6 way without worrying about whether the existing environment supports it.

 The original code above uses an arrow function, and Babel converts it into a normal function, which can be executed in a JavaScript environment that does not support arrow functions.

3. let and const commands

let definition

ES6 has added the let command to declare variables, and its usage is similar to var

2.1 var exists variable promotion

let and const do not exist

 2.2 The same name cannot be defined repeatedly in the same scope

 

 

4. Arrow functions

 

 

 

 

 

 The pit of the arrow function:

Arrow functions cannot be used as constructors, and the new command cannot be used

Constructors are templates for generating objects

 

There is no arguments object in the arrow function, the object does not exist in the function body, instead of rest 

 

 5. Deconstruction

what is deconstruction

ES6 allows extracting values ​​from arrays and objects and assigning values ​​to variables according to a certain pattern, which is called destructuring

Deconstruction is a new feature of ES6, which is simpler and clearer than ES5 code, reducing the amount of code

Assigning values ​​to variables in ES5 can only specify values ​​directly.

 

 

6、set 

 

 

7.map

 

 

 

 

Guess you like

Origin blog.csdn.net/a_xia_o/article/details/132034345