Es6 extension operator query

< H1 > Ruan Yifeng: the extension operator (spread) is three dots (.). It is like the inverse operation of rest parameters, converting an array into a sequence of parameters separated by commas. < / H1 >

what does the inverse operation of rest parameters mean? what does
parameter sequence mean? What kind of data structure is it?

I want to know how the extension operator works

Feb.28,2021

there is no principle, it's just grammatical candy. The former spread you already know, the latter can search for the keyword "deconstruction".

there are many articles about these two things, and here is only one example

var arr = [1, 2, 3];

function test(...args) {
  console.log(args);
}

test(1, 2, 3);
// [ 1, 2, 3 ]

test(...arr);
// [ 1, 2, 3 ]

var [a, ...b] = arr;
// a = 1, b = [2, 3]

  1. when you look at the rest of the function section, you can use the form of function (.arr) {} to accept all the incoming things into the arr (the name is optional when you define it). Then the extension operator is the reverse process, spreading out the collected things again.
  2. A
  3. parameter sequence is something similar to arguments, which is a sequence containing function parameters--.
  4. I don't know how it is implemented at the bottom.
Menu