数组方法slice()把类数组转成数组和复制一个数组

时间:2022-03-26 19:03:00
function a(){

	console.log(arguments.length);
	var c = [].slice.call(arguments);//类数组转成数组
	c.push(5);
	console.log(c);
	console.log(arguments);
}


a(1,2,3)

 

var a = [1,2,3],

 	b = a.slice(0);

 	a.push(5);

	console.log(a);
 	console.log(b);