//将对象属性用作实参
//将原始数组的length元素属性复制到目标数组
//开始复制原始数组的from_start元素
//并且将其复制至目标函数的to_start中
function arraycopy(/* array*/ from, /* index */ from_start,
/* array */ to, /* index */ to_start ,/* integer */ length)
{
//逻辑代码;
for(var i =0; i <length;i++)
{
to[to_start+i] = from[from_start+i];
}
}
function easycopy(args)
{
arraycopy(args.from,
args.from_start || 0,//这里设置了默认值
args.to,
args.to_start || 0, args.length);
}
//调用easycopy()
var a = [1, 2, 3, 4],b = [];
easycopy({from: a, to:b, length:4});for(p in b)alert(b[p]);
}