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

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

如:

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

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

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

var array = new Array();

array.slice.call(arguments);

array.slice(start,end)

console.log([1,2,3].slice());
//[1, 2, 3]
console.log([1,2,3].slice(1,3));
//[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. SpringBoot配置属性之DataSource

    https://segmentfault.com/a/1190000004316491

  2. Spring3:AOP

    AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object Oriented Programming,面向对象编程)的补充和完善.OOP引入 ...

  3. Python笔记-第一天

    1.Python的输出print函数要把输出的字符串用单引号或者双引号括起来,但是不能混用. 比如print('hello,world')和print("hello,world") ...

  4. MVC 缓存实践(一)

    为什么要讲缓存.缓存到底有什么作用? 下面我们来说一个场景我们有一个首页菜单的布局基本是不会经常发生的变化,如果动态生成的 Web 页被频繁请求并且构建时需要耗用大量的系统资源,那么,如何才能改进这种 ...

  5. Multiple annotations found at this line

    Multiple annotations found at this line 在使用MyEclipse的时候,通过MVN导入项目时候,webapp下面的JSP页面报了如下的错误: 这种情况通常的原因 ...

  6. scrapy爬虫笔记(二)------交互式爬取

    开始网页爬取:(1)交互式爬取 首先,我们使用scrapy建立起爬虫的框架.在命令行中输入 scrapy shell “url” 如:scrapy shell “http://www.baidu.co ...

  7. #20145205 《Java程序设计》第4周学习总结

    教材学习内容总结 1.面对对象中,因为我们需要设计多个模块,但是有不能像C语言中那样进行分块设计,所以我们用父类和子类进行模块的设计,我们在设计一个较大的程序时,在一个项目中建立不同的文件,用关键字e ...

  8. OFFSET 函数

    转自http://office.microsoft.com/zh-cn/excel-help/HP010342739.aspx OFFSET 函数 全部显示 全部隐藏 本文介绍 Microsoft E ...

  9. 学习Http协议和当下主流的Rx+Retrofit的主流框架

    所有的劳累都会烟消云散了.不只在生活上,也对我的心态上发生了翻天覆地的变化.在和她在一起之前,我总觉得自己很小,不会去站在别人的角度替别人思考问题,没事就乱发脾气,抑或是一直沉迷于游戏.而和她在一起后 ...

  10. [转载] Ubuntu 16.04 LTS 一键安装VNC

    安装 X11VNC: sudo apt install x11vnc -y 配置访问密码: sudo x11vnc -storepasswd /etc/x11vnc.pass 创建服务: vi /li ...