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. sublime text 3 上安装xdebug

    安装完成之后启动xdebug,缺省设置下会显示warning等信息,很不方便. 可以参考 https://github.com/martomo/SublimeTextXdebug/blob/maste ...

  2. UWP App Services in Windows 10

    1.AppServices in Universal Windows Platform(UWP) UWP 应用服务可以提供给另一个UWP应用.在Win10系统中,一个应用服务当作应用的一个方法和机制来 ...

  3. JS 封装一个判断闰年平年的方法 aa(nian)

    nn(2017) function nn (nian){ if(nian%4 == 0 && nian%100 !== 0 || nian%400 ==0 ) { alert(&quo ...

  4. Django之瀑布流

    一. 小功能瀑布流的实现 1.完成效果图 2.代码部分 <1>models.py from django.db import models # Create your models her ...

  5. ftp服务器在linux中安装

    1.安装 执行 yum -y install vsftpd 2.检验是否安装vsftpd : rmp -qa | grep vsftpd      默认配置文件/ect/vsftpd/vsftpd.c ...

  6. Windows使用docker打开新窗口error解决办法

    环境 win7 Error: error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.26/containers/json ...

  7. BZOJ 3674 可持久化并查集加强版(按秩合并版本)

    /* bzoj 3674: 可持久化并查集加强版 http://www.lydsy.com/JudgeOnline/problem.php?id=3674 用可持久化线段树维护可持久化数组从而实现可持 ...

  8. SQL-Oracle-创建Dblink

    create database link DBLINK_IMARK_RAC connect to imark identified by imarkDB12345 using '(DESCRIPTIO ...

  9. rails Installer之后的调整rails.bat等文件

    rails Installer之后的调整rails.bat文件 出现系统找不到指定路径 学习了:http://www.jianshu.com/p/065355a731ee 修改rails.bat为 @ ...

  10. 用 query 方法 获得xml 节点的值

    DECLARE @result xml SET @result='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelo ...