ES6 little dot operator

1. rest (variable) parameter
* arguments than to replace the arguments but flexible, is only part of the last parameter Parameter

 function add(...values) {
    let sum = 0;
    for(value of values) {
      sum += value;
    }
    return sum;
  }

2 bit dot operator

let fg=[3,4,5]
let arr = [2,3,4,5,6];
    let arr1 = ['abc',...arr,...fg];
    console.log(arr1);//2,3,4,5,6,3,4,5,

 

Guess you like

Origin www.cnblogs.com/hack-ing/p/12005924.html