美文网首页让前端飞
Array.prototype.slice.call(argum

Array.prototype.slice.call(argum

作者: 穆熙沐 | 来源:发表于2017-01-05 18:45 被阅读142次

Array.prototype.slice.call(arguments)能将具有length属性的对象转成数组.
首先,slice有两个用法,一个是String.slice,一个是Array.slice,第一个返回的是字符串,第二个返回的是数组,这里我们看第2个。
Array.prototype.slice.call(arguments)能够将arguments转成数组,那么就是arguments.toArray().slice();到这里,是不是就可以说Array.prototype.slice.call(arguments)的过程就是先将传入进来的第一个参数转为数组,再调用slice?

slice的内部实现:

Paste_Image.png

附:文件上传过程:

Paste_Image.png

相关文章

网友评论

    本文标题:Array.prototype.slice.call(argum

    本文链接:https://www.haomeiwen.com/subject/stwzvttx.html