一、ES5 伪数组转数组

伪数组:arguments
转换方法:

let args = [].slice.call(arguments);

举个例子:

将 NodeList 转数组

let items = [].slice.call(document.querySelectorAll('item'));

二、ES6 伪数组转数组

伪数组:arguments
转换方法:

let args = Array.from(arguments);

举个例子:

将 NodeList 转数组

let items = Array.from(document.querySelectorAll('item'));

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-10-26
  • 2021-11-20
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2017-12-16
相关资源
相似解决方案