zxmonster

类数组(伪数组)

类数组(伪数组): Array-like和数组很像,有length属性,但是没有数组的方法。

常见的类数组有:

  1: 函数内置的arguments对象;

  2:通过document.getElementsByTagName()获取的元素,为一个HTMLCollection()集合;

  3:通过document.getElementByName()获取的元素,为一个NodeList[]集合;

类数组转为数组: 当我们要使用数组的一些方法的时候,就要先将类数组转为数组

  1:

    Array.prototype.slice.call();

  2:

    Array.from();这个方法是es6中的方法;

打印结果为:

   

 

 

  

发表于 2018-05-30 16:04  catEssence  阅读(260)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
猜你喜欢
  • 2021-10-23
  • 2019-09-12
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
相关资源
相似解决方案