function obj(){
var args=Array.prototype.slice.call(argumens);
console.log(args);
}
obj("h","e","l","l","o"); //输出 ["h","e","l","l","o"];
arguments是函数内置的类数组对象。文章详见函数内置arguments。
那么在obj函数内部的
arguments={
0:"h",
1:"e",
2:"l",
3:"l",
4:"o",
length:5
};
这里Array.prototype.slice.call(arguments)的内部是如何执行的才会输出["h","e","l","l","o"]的?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
可通过call或者apply方法,对象冒充
先看下我对 apply、call和bind这三个你可能感兴趣的理解,然后或许你就懂了你要问的了,http://www.cnblogs.com/skylor/p/4723612.html