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. js判断是iOS还是Android

    <script type="text/javascript"> var ua = navigator.userAgent.toLowerCase(); if (/iph ...

  2. 免费领取百度云盘2048G永久空间,永久离线下载特权

    百度云盘和360云盘之间的竞争可谓争锋相对,前段时间,百度和360就网盘免费都采取了自己的措施,最终,360一锤定音,直接免费送36T,并且如果你超过了36T的容量,还可以自动免费扩容! 可参看文章: ...

  3. python中文注释报错问题

    错误信息: SyntaxError: Non-ASCII character '\xe4' in file... 解决办法: 在文件第一行或第二行添加:# -*- coding: utf-8 -*- ...

  4. HTML5分节元素和语义元素

    <base> <base> 元素为文档中的所有链接指定基地址.如果URL中含有协议名或"//"则会忽略 <base> 指定的基地址. <! ...

  5. jquery 图片没有路径,不显示图片。

    $("img").each(function () { if ($(this).attr("src").trim() == "") { $( ...

  6. CSS方法论完全总结

    软件开发领域所有的工程问题,归根结底衍生自一个问题:代码量大了怎么办? 对于CSS而言,因代码量增大导致的核心问题是命名冲突. 解决命名冲突的方法论是模块化,围绕此方法论,演化出种种模块化方案. 一. ...

  7. 20145220&20145209&20145309信息安全系统设计基础实验报告(4)

    20145220&20145209&20145309信息安全系统设计基础实验报告(4) 实验报告链接: http://www.cnblogs.com/zym0728/p/6132246 ...

  8. ASP.Net一键自动化更新代码、编译、合并dll、压缩js、css、混淆dll、zip打包、发布到测试环境的bat批处理

    不废话,直接代码: D: cd D:\src\testproj\PrecompiledWeb svn revert ../ -R svn update .. rmdir BS /S /Q C:\Win ...

  9. 学习laravel遇到的一些错误

    Call to undefined method Illuminate\Foundation\Application::bindShared() 错误代码 Call to undefined meth ...

  10. 弱网测试IOS

    IOS测弱网非常方便,在设置-开发者-NETWORK LINK CONDITIONER的Status 进入后可以看到IOS自带了100%LOSS.3G.WiFi等常见场景 可以点击图标i进行查看或编辑 ...