Deconstruction of ES6, talk about application scenarios

The difference between await and promise

ES6 inheritance and ES5 differences

An ES6 class can be thought of as just a syntactic sugar for the constructor of an ES5 generated instance object. It references the Java language and defines a class concept that makes object prototyping clearer and object instantiation more like object-oriented programming. Class classes can be inherited through extends. It differs from the ES5 constructor in that all methods defined inside a class are not enumerable. 2.ES6 classes must be operated with the new command, while ES5 constructors can be executed without new. 3. The ES6 class does not have variable promotion and must be defined before instantiation, unlike ES5 where constructors can be written after instantiation. 4. The essence of ES5 inheritance is to create the instance object of the subclass this, and then add the methods of the parent class to this. ES6 has a completely different inheritance mechanism, essentially adding the properties and methods of the superclass instance object to this (so the super method must be called first), and then modifying this with the constructor of the subclass.

Difference between CommonJS and ESM

Es6 array methods, which will change the original array

What are the properties of the arrow function

  • The arrow function’s this always points to the outer function’s this
  • The arrow function cannot be a constructor because of the problem this points to
  • Arrow function is not defined in the arguments keywords, parses the arguments to outer function, want to get the arrow function of parameters can use ES6 remaining (… Operator) property
  • If the arrow function contains only one expression, the curly braces and return statement of the function body can be omitted, and the expression is treated as the return value
  • The arrow function is a class member method. The arrow function this points directly to the instance object of the class. There is no need to manually bind the this pointer

Blog.csdn.net/qq_39200185…

Why don’t arrow functions have this

  • Because arrow functions have no scope of their own. So the arrow function’s this shares a scope with the caller
  • The this inside the arrow function is replaced by a variable at compile time

Differences between map and foreach

Similarities:

  • It’s a loop over each term in the set
  • Each execution of an anonymous function takes three arguments: item (current item), index (index value), and arR (original array)
  • This in anonymous functions refers to the window
  • You can only iterate over groups of numbers

The difference between

  • Map () allocates memory to store the new array and returns it; forEach() does not return data
  • ForEach () allows callback to change the elements of the original array. Map () returns a new array

Application scenarios

www.jianshu.com/p/6146bf9c6…

Es6.ruanyifeng.com/#docs/destr…

www.cnblogs.com/zhengyan/p/…