转圈圈

# toArray

目录:

  1. Array.prototype.slice.call
  2. Array.from
  3. Array.of
  4. const toArr = (...args) => args

Array.prototype.slice.call

类数组对象(Array-like)

/** argument 类数组对象 */
Array.prototype.slice.call(arguments)

/** 简写 */
[].slice.call(arguments)

Array.from

参数:类数组对象、可迭代的对象

Array.from(arrayLike[,mapFn[,thisArg]])
// 用法
Array.from(arguments)

Array.of

Array(7) // 创建一个长度为7的空(empty)数组 [,,,,,,]
Array.of(7) // [7]

toArr

剩余参数语法

const toArr = (...args) =>  args
toArr(1,2,3,4) // [1,2,3,4]
posted @ 2019-05-29 21:16  rosendolu  阅读(93)  评论(0编辑  收藏  举报