What is the understanding of es6's extension operator?

in es6. The extension operator expands the array

[1Magol 2pr 3] unfolds as 1Magol 2Jol 3, so what is this 1Magol 2Jol 3? An array is not an array, a string is not a string

later, there was also the operation of the object. The operator
is called deconstructing assignment?
let {x, y, .z} = {x: 1, y: 2, a: 3, b: 4};
assigns all the properties of the target object to the specified object?
makes the target object have this object attribute value?

Feb.28,2021

when you look at something, you should click on it. It is wrong to use .arr alone.

  1. array . extension operator

    function demo (a, b) {
        console.log(a, b)
    } 
    demo(...[1, 2])// 1 2
    demo([1, 2]) //[1, 2] undefined
    // demo(arr[0], arr[1])
    // 
  2. what is deconstruction assignment
    I believe you should understand this

    let {a: a, b: b} = {a: 1, b: 2}
    a // 1
    b // 2
    // {a, b} = {a: 1, b: 2}
    // 
  3. deconstruct the extension operator of assignments and objects

    let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }
    // xy
    // ...za:3, b:4
    // z`{a: 3, b: 4}`
  4. if you are reading the book introduction to es6, be sure to type the code. At the same time, the later examples in the book will use the previous things, so don't think about it separately.
Menu