js函数arguments对象

定义

arguments 是 函数接受的参数集合 是 伪数组 无法正常调用数组方法

伪数组转数组方式

function fn(){
	console.log([].slice.call(arguments, 1 , 2));//[1]
	console.log(Array.prototype.slice.call(arguments,1,2))//
	
}
fn(0,1,2,3,4)

猜你喜欢

转载自blog.csdn.net/weixin_42043407/article/details/121421127