13 new features of ES10 (small knot)

ES10的13个新特性示例(小结)

ES10 is an ECMAScript version corresponding to 2019. The new features in this release are not in ES6 (2015). However, there are no useful features.

This article describes the functions provided by ES10 in a simple code example. This way, you can quickly understand new features without complex explanation.

Of course, it is necessary to have JavaScript basics to fully understand the new features described.

JavaScript new features in ES2019 include:

Array # {flat, flatmap}

  • Object.Fromentries
  • string # {Trimstart, Trimend}
  • Symbol # description
  • Try {} catch {} // Optional error parameter binding
  • JSON ⊂ ECMAScript
  • has good format JSON.STRING1
  • Stable sorted Array # sort
  • New Function # toString
  • New Bigint Original Type (Stage 3).
  • Dynamic introduction module (Stage 3).
  • Standard GlobalThis object (Stage 3).

  • ES10 Class: Private, Static & Public (Stage 3).

  • Array.Flat () & array.flatmap ()

Two new array methods:

ARRAY.FLAT () method creates a new array, all sub-array elements are incorporated into the array until the specified depth is reached.

Array.FlatMap () method First use the MAP function to convert each element, and then the result is flattened as the new array. It is the same as the FLAT () effect that is represented by the mAP (), but flatmap () combines both into a method, more efficient.

Object.fromentries ()

ES10的13个新特性示例(小结) converts the key value to the two-dimensional array of components into an object.

String.Protype.matchall ()

Matchall () method returns all the results of matching strings with regular expressions Iterator, including capture groups.

ES10的13个新特性示例(小结)

String.trimstart () & string.trimend ()

There are two new String methods to be from the string Delete space:

TrimStart () method deletes spaces from the beginning of the string.

Trimend () method deletes spaces from the end of the string. ES10的13个新特性示例(小结)

Symbol.description

When a symbol is created, a string can be provided as a description. In ES10, there is a acquisition of the visitor.

Optional CATCH parameter variable

ES10的13个新特性示例(小结) In the past, the CATCH clause in the TRY / CATCH statement requires a variable. Now it allows developers to use TRY / CATCH without creating unused ERROR variable binding.

JSON⊂ECMAScript

In the version before ES10, non-proportional line separator U + 2028 is not accepted. Paragraph separator U + 2029.

U + 2028 is a paragraph separator.

u + 2029 is a linear separator. ES10的13个新特性示例(小结)

JSON.STRINGY ()

json.stringify () may return U + D800 and U + DFFF The characters are used as values ​​without equivalent UTF-8 characters. However, JSON format requires UTF-8 encoding. The solution is that unpacking alternative code points are represented as a JSON escape sequence instead of returning it as a single UTF-16 code unit.

ES10的13个新特性示例(小结)

Array.Prototype.sort ()

V8 is previously implemented, the array containing 10 or more items is not Stable fast sort algorithm.

A stable sorting algorithm is that when two objects that have the same key appear in the order of order output, the order in which the unsorted input occurs.

New Function.toString ()

ES10的13个新特性示例(小结)

TOSTRING () method returns a string representing the function source code. In ES6, when TOSTRING is called on the function, it will return the string representation of the function according to the ECMAScript engine. If possible, it will return source code, otherwise, a standardized placeholder.

Bigint – Integer of any precision

Bigint is the seventh original type, which is an integer of any precision. Not just at 90071992547The maximum value at 40992.

ES10的13个新特性示例(小结)

Dynamically introduced

Dynamic import () returns the Promise of the requested module. Therefore, you can use Async / AWAIT to assign the imported module to the variable.

Standard GlobalThis Object ES10的13个新特性示例(小结)

Global THIS is not standardized before ES10. In the production code, you can “standardize” by writing the following code:

ES10 Class: Private, Static & Public Member Variable, Function

Now, new syntax characters # (hash tags) are used to define variables, functions, getter, and setter directly in the class, and constructor and class methods. ES10的13个新特性示例(小结)

Summary

Since the emergence of ES6 in 2015, this language has been in a state of rapid development. In this article, we reviewed the features in ES10 (2019) and introduced some functions that will remain stable in ES11 (2020) because they are in state 3, and may eventually implement standardization in the next version. .

Although many features in these functions may not be required for web applications, they provide the likelihood that the skill or a lot of lengthy code can be implemented.

ES10的13个新特性示例(小结) The above is all the content of this article, I hope to help everyone, I hope everyone will support Tumi Cloud.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment