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. Spring boot application.properties 配置

    原文链接: http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.ht ...

  2. 基准测试-jmeter压力测试activeMQ之一环境安装配置

    jmeter压力测试activeMQ 摘要:linux(CentOS)单机activeMQ安装.window(2008Server)Jmeter配置activeMQ包.Jmeter配置linux监控 ...

  3. js去除html标记

    function ff(str) { var dd = str.replace(/<\/?.+?>/g, ""); var dds = dd.replace(/ /g, ...

  4. 创建一个dynamics CRM workflow (三) - Creating Configuration Entity for Custom Workflow

    上个帖子中, 我们创建了个发email的workflow. 但是我们邮件当中的tax 值是 hard code, 这在开发当中是不容许的. 那今天我们来把这个build in workflow用 in ...

  5. WIN10打开网络共享文件夹提示0x80004005怎么解决?(转载)

    发布时间:2018-07-04 12:48 来源:www.pipimp3.com 作者:笔记本系统 WIN10打开网络共享文件夹提示0x80004005怎么解决?针对这个问题,小编整理了方案,有兴趣的 ...

  6. centos7 rpm 安装 rabbitMQ 最新版

    首先打开官网: http://www.rabbitmq.com/install-rpm.html 先到右侧导航栏来看一下 : 第一个红框是指的在linux中安装,全英文的,乱的一笔,但是静下心来就可以 ...

  7. Vue双向绑定

    vue的双向数据绑定的原理相信大家都十分了解:主要是通过ES5的Object对象的defineProperty属性:重写data的set和get函数来实现的. 该方法允许精确的添加或者修改对象的属性: ...

  8. 搞定PHP面试 - 函数知识点整理

    一.函数的定义 1. 函数的命名规则 函数名可以包含字母.数字.下划线,不能以数字开头. function Func_1(){ } //合法 function func1(){ } //合法 func ...

  9. css文本两端对齐

    在做表单时我们经常遇到让上下两个字段对齐的情况,比如姓名, 手机号码, 出生地.这样我们就要用到 text-align, text-justify样式了. text-align直接设为justify就 ...

  10. ZOJ 3891 K-hash

    K-hash Time Limit: 2000ms Memory Limit: 131072KB This problem will be judged on ZJU. Original ID: 38 ...