类数组对象转化为数组
let arrayLike = { ‘0‘: ‘a‘, ‘1‘: ‘b‘, ‘2‘: ‘c‘, length: 3 }; let arr = Array.from(arrayLike) arr.forEach(el=>console.log(el))
输出结果:[a,b,c],需要注意的是,length不能少
原文地址:https://www.cnblogs.com/leileilei/p/10985990.html
时间: 2024-10-10 20:31:43
类数组对象转化为数组
let arrayLike = { ‘0‘: ‘a‘, ‘1‘: ‘b‘, ‘2‘: ‘c‘, length: 3 }; let arr = Array.from(arrayLike) arr.forEach(el=>console.log(el))
输出结果:[a,b,c],需要注意的是,length不能少
原文地址:https://www.cnblogs.com/leileilei/p/10985990.html