Array.prototype.slice.call(arguments)能够将具有length属性的对象转化为数组,

可以理解为将arguments转化成一个数组对象,让它具有slice方法

如:

  1. function test(){
  2. console.log(Array.prototype.slice.call(arguments));
  3. }
  4. test(1,2);

Array是一个类,不能直接引用,需要获取原型后才能使用。

如果要直接引用,需要实例化array

  1. var array = new Array();
  2.  
  3. array.slice.call(arguments);

array.slice(start,end)

  1. console.log([1,2,3].slice());
  2. //[1, 2, 3]
  3. console.log([1,2,3].slice(1,3));
  4. //[2, 3]

call的作用是改变this的指向,相当于arguments调用了slice这方法

Array.prototype.slice.call(arguments)的更多相关文章

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

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

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

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

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

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

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

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

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

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

  6. Array.prototype.push.apply(a,b)和Array.prototype.slice.call(arguments)

    Array.prototype.push.apply(a,b) 时常看到在操作数组的时候有这样的写法: var a = [1,2,3]; var b = [4,5,6]; a.push.apply(a ...

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

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

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

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

  9. [转载]Array.prototype.slice.call(arguments,1)原理

    Array.prototype.slice.call(arguments,1)该语句涉及两个知识点. arguments是一个关键字,代表当前参数,在javascript中虽然arguments表面上 ...

随机推荐

  1. Leetcode Word Ladder

    Given two words (start and end), and a dictionary, find the length of shortest transformation sequen ...

  2. @寒冬winter 大神的css作业问题

    块级元素   ①总是在新行上开始: ②高度,行高以及外边距和内边距都可控制: ③宽度缺省是它的容器的100%,除非设定一个宽度. ④它可以容纳内联元素和其他块元素 行内级元素   ①和其他元素都在一行 ...

  3. 【Linux】lsof 命令,记一次端口占用查询

    3月21日测试时,发现测试服务器启,总是报端口占用情况,察看端口占用情况 1-使用命令 netstat -tunlp |grep 端口号 差看下 这个端口被那个进程占用 我当前使用的 JBOSS 端口 ...

  4. Linux crontab 命令格式与详细例子

    基本格式 :* * * * * command分 时 日 月 周 命令 第1列表示分钟1-59 每分钟用*或者 */1表示第2列表示小时1-23(0表示0点)第3列表示日期1-31第4列表示月份1-1 ...

  5. (转)基于socket的TCP和UDP编程

    一.概述 TCP(传输控制协议)和UDP(用户数据报协议是网络体系结构TCP/IP模型中传输层一层中的两个不同的通信协议. TCP:传输控制协议,一种面向连接的协议,给用户进程提供可靠的全双工的字节流 ...

  6. HUAS_ACM 个人训练#2 C

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=117538#problem/C 题目大意:给出一个字符串,然后给出一系列的x,y ...

  7. ADT Ubuntu X64 下ia32-libs替换等【待编辑】

    sudo apt-get install ia32-libs apt-get install libglib2.0-0:i386 libpng12-0:i386 libsm6:i386 libxren ...

  8. win10启动无法进入桌面

    情况: windows启动显示欢迎界面 无法进入桌面(可以win+E进入资源管理器,可以ctl+alt+delete进入任务管理器) 重启依然无法进入 解决: 重启 按f8 进入安全模式 再次重启OK ...

  9. Hibernate 二级缓存的配置及使用_EhCache

    大多数的应用程序中都会添加缓存模块,以减少数据库访问次数,同时增加响应速度.下面介绍一下hibernate的二级缓存.默认情况下hibernate的二级缓存是不开启的,我们需要手动配置并启用. 注: ...

  10. Mac&iOS之多线程--转自http://geeklu.com/2012/02/thread/

    http://geeklu.com/2012/02/thread/ 首先循环体的开始需要检测是否有需要处理的事件,如果有则去处理,如果没有则进入睡眠以节省CPU时间. 所以重点便是这个需要处理的事件, ...