扩展运算符,箭头函数和参数默认值,剩余参数,拓展参数

扩展运算符

let zzz=[2,4,6];
console.log(zzz);//[2, 4, 6]
console.log(...zzz);//2 4 6

let a=[1,2,3];
let b=[...a,4,5,6];
console.log(b);//1,2,3,4,5,6

let [a,b,...c]=[1,2,3,4,5];
console.log(a,b);//1 2
console.log(c);//[3, 4, 5]

箭头函数

let say333=()=>{
	console.log("333");//333
}
say333();

(name)=>{
	console.log(name);
}

(a,b)=>{
	return a+b;
}

(a,b)=> a+b;

参数默认值,剩余参数,拓展参数

let aa=(name='wwrs')=>{
	    console.log(`Hello ${name}`);
	}
	aa();//Hello wwrs
	aa('sss');//Hello sss
	
	
let bb=(a,b,c)=>{
		console.log(a+b+c);//9
	}
	let dd=[2,3,4];
	bb(...dd);
	
	
let he=(a,b,c,d)=>{
	console.log(a+b+c+d);//10
}
he(1,2,3,4)

let he1=(s,j,...shi)=>{
	console.log(shi);//[3, 4]
}
he1(1,2,3,4)
posted @ 2017-07-13 08:52  CoCo5  阅读(288)  评论(0编辑  收藏  举报