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. Programming Recipes

    Recipes是从一本书上看来的,即有诀窍又有食谱的意思.这里想记一些工作中遇到的问题和解决方法,说决窍有点过了,说食谱照单做又不足,所以Recipe这个词两个意思都有混合起来正合适. 1.Windo ...

  2. .NET 请求和接收FormData的值

    <body> <div> <!-- 上传单个文件---> <form action="/Home/UpdateFile2" enctype ...

  3. U盘启动盘安装Mac OS

    1.下载macOS High Sierra正式版 http://www.pc6.com/mac/gj_715_1.htm http://www.pc6.com/mac/518996.html 下载ma ...

  4. centos solr 集群搭建

    一.什么是 SolrCloud SolrCloud(solr 云)是 Solr 提供的分布式搜索方案,当你需要大规模,容错,分布式索引和检索能力时使用 SolrCloud.当一个系统的索引数据量少的时 ...

  5. 02springMVC理解DispatcherServlet

    DispatcherServlet的作用 DispatcherServlet在Web.xml中的配置 上下文关系 DispatcherServlet初始化顺序 DispatcherServlet中使用 ...

  6. asp.net mvc-identity初步学习

    Install-Package Microsoft.AspNet.Identity.EntityFramework Install-Package Microsoft.AspNet.Identity. ...

  7. BA-给排水-供水系统自动控制(转载)

    浙江省建筑设计研究院划 杨绍胤 杨庆 摘 要:探讨供水系统变流量和恒压自动控制和设计方法.关键词: 供水系统 自动控制 传统给水系统常在屋顶设置高位水箱.水从地下水箱用水泵打到高位水箱.从高位水箱通过 ...

  8. [SharePoint2010开发入门经典]10、使用SPS2010构建面向服务的应用程序

    本章概要: 1.使用SPS自带的web service 2.构建自定义web service 3.使用不同的客户端解决方案部署自定义站点

  9. [SharePoint2010开发入门经典]四、开发者常见任务

    本章概要: 1.创建不同种类的web部件,包括标准的,可视化的还有数据绑定web部件 2.理解列和内容类型,如何使用它们创建列表 3.理解如何与SPS交互,使用SPS API调用数据 4.创建编辑页面 ...

  10. centos6安装eclipse

    1. 下载eclipse 我下载的是eclipse-jee-juno-SR2-linux-gtk-x86_64.tar.gz 能够在http://www.eclipse.org/downloads/处 ...