<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> /* 因为arguemnets不是一个数组,而是一个Object,而我们有时候需要将arguemnets进行类似数组的操作,所以就需要将arguements进行 数组化的操作。 通过Array.prototype.slice.call(arguements);这个方法能初始化所有具有length属性的对象,但是IE下的节点集合不可以,应为IE下的 节点集合使用com对象实现的而com对象不能和js对象进行相互转化 */ var arguements={length:2,0:'first',1:'second'}; //注意这个对象必须要有length属性,否则无法对对象进行数组化 /* Array.prototype.slice.call(arguements); 代码解析:arguements对象将Array.prototype.slice对象编译成自己的内部属性,从而可以使用Array.prototype.slice对象中的所有属性和方法 //然后给调用slice方法,并通过arguements后面的参数,给slice传参 */ alert([].slice.call(arguements,0));//输出:first,second </script> </body> </html>