Array.prototype.slice.call(arguments)
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)的更多相关文章
- 详解 Array.prototype.slice.call(arguments)
首先,slice有两个用法,一个是String.slice,一个是Array.slice,第一个返回的是字符串,第二个返回的是数组 在这里我们看第二个方法 1.在JS里Array是一个类 slice是 ...
- Array.prototype.slice.call(arguments) 类数组转成真正的数组
Array.prototype.slice.call(arguments) 我们知道,Array.prototype.slice.call(arguments)能将具有length属性的对象转成数 ...
- 转对象(含length属性)成数组Array.prototype.slice.call(arguments)
我们知道,Array.prototype.slice.call(arguments)能将具有length属性的对象转成数组,除了IE下的节点集合(因为ie下的dom对象是以com对象的形式实现的,js ...
- js基础进阶--关于Array.prototype.slice.call(arguments) 的思考
欢迎访问我的个人博客:http://www.xiaolongwu.cn Array.prototype.slice.call(arguments)的作用为:强制转化arguments为数组格式,一般出 ...
- 理解Array.prototype.slice.call(arguments)
在很多时候经常看到Array.prototype.slice.call()方法,比如Array.prototype.slice.call(arguments),下面讲一下其原理: 1.基本讲解 1.在 ...
- 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 ...
- [转] 理解 JavaScript 中的 Array.prototype.slice.apply(arguments)
假如你是一个 JavaScript 开发者,你可能见到过 Array.prototype.slice.apply(arguments) 这样的用法,然后你会问,这么写是什么意思呢? 这个语法其实不难理 ...
- javascript:Array.prototype.slice.call(arguments)
我们知道,Array.prototype.slice.call(arguments)能将具有length属性的对象转成数组,除了IE下的节点集合(因为ie下的dom对象是以com对象的形式实现的,js ...
- [转载]Array.prototype.slice.call(arguments,1)原理
Array.prototype.slice.call(arguments,1)该语句涉及两个知识点. arguments是一个关键字,代表当前参数,在javascript中虽然arguments表面上 ...
随机推荐
- mac os x 10.10.3 安装protoc
预装如下环境 autoconf 2.6.9automake 1.14libtool 2.4 Building from source Download latest version of procbu ...
- XVI Open Cup named after E.V. Pankratiev. GP of Eurasia
A. Nanoassembly 首先用叉积判断是否在指定向量右侧,然后解出法线与给定直线的交点,再关于交点对称即可. #include<bits/stdc++.h> using names ...
- 我的jQuery源码读后感
(function(window, undefined) { // 构造jQuery对象 var jQuery = (function() { var jQuery = function(select ...
- js 爱恨情仇说 this
this 相信大家在写代码的时候都会遇到,可是怎么样才能用好this,估计这个还是有点困难的,虽然你有时候你会用到,但是他所在的具体的几个场景中所代表的是什么意思了?可能这个你就不是很清楚啊.这个就会 ...
- linux 添加 service 服务并自动添加 chkconfig 启动级别
下面以添加一个叫做watchcat的服务为例进行说明: 1.写一个提供给service命令使用的脚本 service 命令的使用方法一般如下 启动: $ service watchcat start ...
- onselectstart="return false"
以前在做图片滚动时,在双击左右箭头,快速切换图片滚动时,会选择附近区域的文字,感觉不是很好,今天在查资料时,讲到了这个问题, 试了一下,不错,解决了问题. IE及Chrome下的方法一样,对相应的元素 ...
- Swift与OC混编
OC调用Swift的方法:添加 import "xxxx-Swift.h" 头文件即可 Swift调用OC的方法:需要建立桥接: xxxx-Bridging-Header.h 头文 ...
- PHP 生成PDF
一个项目中需要用到网页生成PDF,就是将整个网页生成一个PDF文件, 以前也用过HTML2PDF,只能生成一些简单的HTML代码,复杂的HTML + css 生成的效果惨不忍睹, 百度了一下,发现有个 ...
- 使用 PHP 内置函数 get_browser() 判断是否是移动浏览器
get_browser — 获取浏览器具有的功能.该函数通过查找 browscap.ini 文件中的浏览器信息,尝试检测用户的浏览器所具有的功能. 由于许可证的问题,PHP 未提供浏览器功能文件,可以 ...
- android 三步实现沉浸式 简单到无法想象
今天产品来看进度,说ios状态栏可以改颜色,以前竟然也没注意过,看了美团 ,扣扣的实现, 才注意到.着手开始做.网上借鉴了点 ,各种乱,整理了下 .希望可以帮到大家 . [转载请标明出处] 前提: ...