注意:剩余参数必须作为函数的最后一个参数出现,其后不能有任何参数 2.作为拓展运算符使用 2.1数组 解构赋值 数组中的扩展运算符就像剩余参数的逆运算,将数组转为用逗号分隔的参数列 console.log(...[1,2,3]); //1 2 3 console.log(1,...[2,3,4],5)//1 2 3 4 5 console.log([1,...[2,3,4],5])//[1
在Typescript 的对象中使用扩展运算符(三个点...),有很大可能会使整个对象的类型检查失效。 示例代码 typeBirdBasicType= {wings:number;name:string; };typeeyePropsType = {eyeInfo: {color:string;open:boolean};};typeOwl= eyePropsType &BirdBasicType;constbasicOwl:BirdBasicType= {wings:2,name:'pete...