Array.prototype.slice.call(arguments,num) 能将具有length属性的对象转成数组。
 
slice 从字面上的意思可以理解为截取数组的一部分。
call 从字面上的意思可以理解为截取出来
arguments 仅与数组类似,不是真正的数组对象,所以它并没有slice这个方法,让arguments转换成一个数组对象,让arguments具有slice()方法。
注:要是直接写arguments.slice(num)会报错。

那么 Array.prototype.slice.call(arguments,num); 即把调用方法的参数截取出来。 

如:

var a={length:2,0:'first',1:'second'};//类数组,有length属性,长度为2,第0个是first,第1个是second
console.log(Array.prototype.slice.call(a,0));// ["first", "second"],调用数组的slice(0); var a={length:2,0:'first',1:'second'};
console.log(Array.prototype.slice.call(a,1));//["second"],调用数组的slice(1); var a={0:'first',1:'second'};//去掉length属性,返回一个空数组
console.log(Array.prototype.slice.call(a,0));//[]
function test(){
console.log(Array.prototype.slice.call(arguments,0));//["a", "b", "c"],slice(0)
console.log(Array.prototype.slice.call(arguments,1));//["b", "c"],slice(1)
}
test("a","b","c");
 

Array.prototype.slice.call(arguments) 通俗法理解的更多相关文章

  1. 理解Array.prototype.slice.call(arguments)

    在很多时候经常看到Array.prototype.slice.call()方法,比如Array.prototype.slice.call(arguments),下面讲一下其原理: 1.基本讲解 1.在 ...

  2. [转] 理解 JavaScript 中的 Array.prototype.slice.apply(arguments)

    假如你是一个 JavaScript 开发者,你可能见到过 Array.prototype.slice.apply(arguments) 这样的用法,然后你会问,这么写是什么意思呢? 这个语法其实不难理 ...

  3. js Array.prototype.slice.call(arguments,0) 理解

    Array.prototype.slice.call(arguments,0) 经常会看到这段代码用来处理函数的参数 网上很多复制粘帖说:Array.prototype.slice.call(argu ...

  4. Array.prototype.slice.call(arguments)

    Array.prototype.slice.call(arguments)能够将具有length属性的对象转化为数组, 可以理解为将arguments转化成一个数组对象,让它具有slice方法 如: ...

  5. 详解 Array.prototype.slice.call(arguments)

    首先,slice有两个用法,一个是String.slice,一个是Array.slice,第一个返回的是字符串,第二个返回的是数组 在这里我们看第二个方法 1.在JS里Array是一个类 slice是 ...

  6. Array.prototype.slice.call(arguments) 类数组转成真正的数组

    Array.prototype.slice.call(arguments)   我们知道,Array.prototype.slice.call(arguments)能将具有length属性的对象转成数 ...

  7. 转对象(含length属性)成数组Array.prototype.slice.call(arguments)

    我们知道,Array.prototype.slice.call(arguments)能将具有length属性的对象转成数组,除了IE下的节点集合(因为ie下的dom对象是以com对象的形式实现的,js ...

  8. js基础进阶--关于Array.prototype.slice.call(arguments) 的思考

    欢迎访问我的个人博客:http://www.xiaolongwu.cn Array.prototype.slice.call(arguments)的作用为:强制转化arguments为数组格式,一般出 ...

  9. javascript:Array.prototype.slice.call(arguments)

    我们知道,Array.prototype.slice.call(arguments)能将具有length属性的对象转成数组,除了IE下的节点集合(因为ie下的dom对象是以com对象的形式实现的,js ...

随机推荐

  1. ZBrush中的PolyPainting如何理解?

    什么是PolyPainting? PolyPainting在ZBrush ®中是一种创建纹理的方法,该方法通过对每个多边形顶点应用单一RGB值来着色模型.此方法无需使用UV坐标.通过直接对顶点应用颜色 ...

  2. 如何避免命令 rm -rf 的悲剧

    一.root高管用户为例,其他用户类同. https://www.cnblogs.com/eos666/articles/10389179.html [root@jenkins /]# vim /ro ...

  3. -ms-,-moz-,-webkit-,-o-含义

    transform:rotate(30deg); //统一标识语句 -ms-transform:rotate(30deg); //-ms代表ie内核识别码 -moz-transform:rotate( ...

  4. swap空间可以有效缓解内存压力

    不太了解底层的人对swap空间的概念也很模糊,这里我简单举例,看看swap空间的作用 查看当前swap空间:3个方式 [root@localhost /home/xxx/kirin/os_diagno ...

  5. JQ淡入淡出效果

    <script type="text/javascript"> //页面淡入淡出 $(document).ready(function() { $('body').hi ...

  6. Project Euler 39 Integer right triangles( 素勾股数 )

    题意:若三边长 { a , b , c } 均为整数的直角三角形周长为 p ,当 p = 120 时,恰好存在三个不同的解:{ 20 , 48 , 52 } , { 24 , 45 , 51 } , ...

  7. Linux 基础入门一

    操作系统1.简介OS: Operating System,通用目的的软件程序操作系统的内核(kernel):  操作系统其实也是一组程序.这组程序的重点在于管理计算机的所有活动及驱动系统中的所有硬件: ...

  8. 2、深入学习基本结构——CNN

    这节课主要简单复习一下CNN 从图中例子,1.3共享参数,2.4共享. 要看明白以上参数. 后面就是举例了. 比如声音信号 下面是zero padding 下面是pooling 还可以有mass po ...

  9. CF789C. Functions again

    /* CF789C. Functions again http://codeforces.com/contest/789/problem/C 水题 题意:求数组中的连续和的最大值 */ #includ ...

  10. 完整的html+css+javascript实现跟随鼠标移动显示选中效果

    1,显示效果: 2,html结构 <div class="process_list-lpu"> <div class="process_line&quo ...