“This is the 8th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”
1. The keywords
The Let keyword works in the code block in which the Let resides. This variable cannot be assigned before letting
The Const keyword is a read-only variable and therefore needs to be assigned when it is defined.
2. Deconstruction
Deconstruction of variables,
1>. Array structure with [], the array parts can be assigned
Such as:
Let [a,,c]=[1,,3]
Let[a,… c] where c can be assigned as an array
2>. Object structure using {}, deconstruction of the object, similar to the array, the difference is that there is a problem with an attribute, the most important is that there is no order of object attributes, but in accordance with the order.
3. The string
1>. Use for of to iterate over each character of a string.
2>. Check whether the following characters are included: include startswith endwith
3>. Padstart… And so on
4>. String template, you can add variables in the string ${variable}. You can also add HTML tags
5>. Numerical values are mostly used to determine whether the function is a number, type conversion, etc
4. The regular
1>
One: Regex r=new Regex(‘ match rule ‘, ‘modify’)
Two: Regex r=/ matched thing/modifier
Regex where I g y is the modifier
2> whether the. Sticky attribute has a modifier
Flags returns the match modifier
3>. Support for trailing assertion
An array of 5.
1>. Assign to const [… a2]=a1
2>. Multiple array merges can be done with []
3>. Combine with knot deconstruction
Such as:
[a,… rest]=list
Function of 6.
1>. Parameter default value, cannot have the same parameter
2>. Parameter pass is lazy evaluation, that is, the default value is recalculated each time
3>. Function assignment can still be done using deconstruction (similar to object deconstruction).
Object of 7.
Objects in ES6 use struct types similar to the original C language, but with the difference that methods can be used inside objects in ES6
Such as:
Const person={Name: wl; Birth, CalTime () {the console. The log (" "); }Copy the code
8.Symbol
1>. It is equivalent to the extra keyword of a definition, preventing the variable of the definition from being accidentally overwritten or overwritten.
2>. The main function is to eliminate magic strings.
9. A collection of
1>. Personal understanding: similar to Java, C# collection. Just because of the nature of ES6, there are several different functions that perform complex operations. A Set can be converted to an array for some deconstruction.
Weak, weak, weak, weak, weak, weak, weak, weak, weak
10.Proxy works with Reflect’s Observer mode
Proxy is an intercepting operation and Reflect is a reflection operation that reads variables and modifies them.
Proxy monitors changes, intercepts operations, and Reflect changes its value to achieve the simplest observation mode
11. Promise
Is a constructor that can call back to two functions. (Personal understanding: more suitable for situations with two results, different functions are called for use in different situations)
An ArrayBuffer is also a constructor that makes use of a variety of function operations, personally felt in order to standardize arrays.
12. Traversal
The traverser simulates Next, moving the pointer until it finishes. In ES6, unlike the C and C++ languages I used before, it will output undefined when it is finished, rather than crash the program.
next: function() { return nextIndex < array.length ? {value: array[nextIndex++], done: false} : {value: undefined, done: true}; // Incrementing nextIndex makes the subscript add itself.Copy the code
13.Generator
The essence is to record the internal state of the function, asynchronous operation, personal feeling should be applied more in multithreading. Single threading didn’t think about the value of the application. Essentially using yield for deferred operations, you can use * instead of yield to make a function deferred.
14.async
Essentially an improved operation of the Generator, which does not use yield for deferred operations, but uses await for deferred operations. But unlike Geneator, which returns a traverser, it returns a Promise object
15.Class
He for the original JS language, the operation of the class, a lot of things are encapsulated, there is a certain template, in order to better read and understand, plus inheritance, but also reduce the writing of repeated code. And the mode is strict mode, more normative for language. This is similar to class in an object-oriented language.
16. The decorator
This is similar to Java annotations, but in a different way. Personally understand Java annotations for code discipline and ease of modification. But in ES6, modifiers are essentially functions that are executed at compile time.
17.Moudle
Modularize something that is statically compiled to make it less repetitive to write, just as Python introduced several libraries to make writing something relatively uncomplicated.
import { stat, exists, readFile } from 'fs'; Export {firstName, lastName, year}; / / outputCopy the code