$A = Array.from(iterable): 将iterable转化为数组,如果iterable定义了toArray方法,就调用这个方法,否则利用iterable的length属性进行枚举, 如果iterable没有length属性的话就返回空数组[]
Array对象除了扩展Enumerable对象的方法外,另外扩展了如下的几个方法,
注意以下方法除了clear外都不改变原来数组,而是返回一个新数组:
clear(): 清除数组,利用arr.length=0
first(): 返回第一个元素
last():返回最后一个元素
compact(): 去除数组中值为null或undefined的元素
flatten(): 将数组扁平化,例如[3,4,[6,7]]变为[3,4,6,7]
without(): 去除指定的元素, 可以指定多个值, 例如[4,56,7,8].without(4,7) 返回[56,8]
indexOf(object): 返回指定的元素在数组中的索引,不包含则返回-1
reverse(inline):Array内置函数reverse的增强,当inline为true时,跟内置的reverse函数效果一样,改变原数组的值,否则不改变原来的值
reduce(): 如果数组只有一个元素,则返回这个元素,否则返回数组本身
uniq(): 返回没有重复元素的数组
clone(): 返回一个跟数组相同的数组,Array中的toArray方法覆盖了Enumerable中的toArray方法,指向了这个方法
inspect(): 跟数组的toString方法类似,返回对象的字符串表示,例如[2,3].inspect() 返回 "[2,3]"
分享到:
相关推荐
prototype.js 1.6中文手册、prototype.js 1.6英文手册、
符合ESnext规范的Array.prototype.at / polyfill / replacement可以使用到ES3。 该软件包实现了接口。 它在ES3支持的环境中工作,并符合建议的。 因为Array.prototype.at依赖于接收方( this值),所以Array....
prototype-1.6.0.3.js prototype1.4中文手册(chm) prototype1.5中文手册(chm) prototype1.6英文手册(chm)
代码如下: function test(){ //将参数转为一个数组 var args = Array.prototype.slice.apply(arguments); alert(args); } arguments在JavaScript语法中是函数特有的一个对象属性(Arguments对象),用来...
$A = Array.from(iterable): 将iterable转化为数组,如果iterable定义了toArray方法,就调用这个方法,否则利用iterable的length属性进行枚举, 如果iterable没有length属性的话就返回空数组[] Array对象除了扩展...
prototype.js 1.4版开发者手册.doc
发现大多人都用了Array.prototype.slice.call(argments,0),一直不明白这句是干什么的。而昨天温习了slice()方法,再参考Function.call(thisArg[, arg1[, arg2[, ...]]]),还是不得而知(我脑筋转得慢:|)。
符合ES2015规范的Array.prototype.values匀场/填充/替换值可一直使用到ES3。 该软件包实现了接口。 它可以在ES3支持的环境中工作并符合。 因为Array.prototype.values取决于接收方(“ this”值),所以Array....
找了好久,才找到下载资源 prototype_1.7.3.js 最新版本
prototype.js 1.4版开发者手册.doc
prototype.js.cn.doc.rar
prototype.js开发手册.pdf
prototype.js源码及API文档, 推荐下载!
prototype.js开发手册prototype.js开发手册prototype.js开发手册
万一你没有使用过大名鼎鼎的prototype.js,那么让我来告诉你,prototype.js是由Sam Stephenson写的一个javascript类库。这个构思奇妙,而且兼容标准的类库,能帮助你轻松建立有高度互动的web2.0特性的富客户端...
利用DREAMWEVER开发网站的插件Prototype。
prototype prototype 1.6中文手册 prototype 1.6中文手册chm 非常详尽,爱不释手
除了正常用法,slice 经常用来将 array-like 对象转换为 true... 查看 V8 引擎 array.js 的源码,可以将 slice 的内部实现简化为: 代码如下: function slice(start, end) { var len = ToUint32(this.length), result =
array.prototype.flatmap 符合ESnext规范的Array.prototype.flatMap填充程序/ polyfill / replacement可以使用到ES3。 该软件包实现了接口。 它在ES3支持的环境中工作,并符合建议的。 因为Array.prototype.flatMap...
prototype.js开发者手册 prototype.js开发者手册 prototype.js开发者手册