The extended operator ES6

Extended operator (...) the array into a sequence of parameters, often used with functions, show (... [ 'judy', 'girl']).

Array merge: [... arr1, ... arr2, ... arr3]

String transfer array of characters: [... "hello"] -------------- [ "h", "e", "l", "l", "o"]

Object implements the Iterator interface into real array: [... nodelist], nodelist here is a nodelist array-like objects.

 

Generator Function: This function returns the object performs a traverse expand operator may also be converted into an array.

let a =function*(){
    yield 3;
    yield 4;
    yield 5;
    return 6;
};
console.log([...a()]);              //[3,4,5]

 

Guess you like

Origin www.cnblogs.com/150536FBB/p/11599548.html