Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the extension operator of ES6

Shulou Source: shulou.com Published: 2022-05-31 13:32:02 09月24日 Update

In this article Xiaobian for you to introduce in detail "how to use the extension operator of ES6", the content is detailed, the steps are clear, the details are handled properly, I hope this article "how to use the extension operator of ES6" can help you solve your doubts, the following follows the editor's ideas slowly in depth, together to learn new knowledge.

What are the spread and rest operators

In ES6, both the spread and rest operators use (...) Where spread is the expansion (expansion) operator and rest is the residual (collection) operator. Using this operator in different places has different functions, which can be considered from both reading and writing perspectives. Among them, the write operation has the collection function, and the read operation has the expansion function. In ES6, (...) Operators are valid only for arrays, and extensions to objects have been added to ES7.

Extension operator of array

Rest operator (collection effect)

Use (.) when not available. Operator, you can only use arguments if you want to implement a summation function with variable arguments. For example:

Function sum () {let sumNumber=0; for (let iTuno witi)

Tags: Operators operations objects presidents universities arrays methods actions parameters practices functions articles differences code traditions content functions properties this method syntax Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei MariaDB NVidia OPPO Reno