https://www.yuque.com/cuggz/feplus/cp4k8o

1. ES6 构造器

Array.of

  • Array.of 用于将参数依次转化为数组项,然后返回这个新数组
  • 与Array构造器功能一致,唯一区别再与单个数字参数处理上
  • image.png

    Array.from

  • 从一个类数组的可迭代对象中创建一个新的数组实例

  • 只要一个对象有迭代器,Array.from 就能把它变成一个数组
  • 该方法返回一个数组,不会改变原对象
  • 该方法有三个参数:
    • 类似数组的对象,必填
    • 加工函数,新生成的数组会经过该函数加工再返回,可选
    • this作用域,表示加工函数执行时this的值,可选
  • image.png
  • 如果不指定this,加工函数可以是一个箭头 函数

image.png

  • 拥有迭代器对象还有String Set Map 等

image.png

2. 数组空位

  • 用逗号创建空位

数组 - 图5

3. 数组索引

  • 通过length可以在数组末尾增加删除元素

    4. 数组判断

    ```tsx // 1. Object.prototype.toString.call() Object.prototype.toString.call(arr).slice(8,-1) === ‘Array’

// 2. constructor arr.constructor === Array

// 3. instanceof arr instanceof Array

// 4. Array.prototype.isPrototypeOf() Array.prototype.isPrototypeOf(arr)

// 5. Object.getPrototypeOf() Object.getPrototypeOf(arr) === Array.prototype

// 6. Array.isArray() Array.isArray(arr) ```