首页 > 编程语言 > 详细

伪数组如何转成数组

时间:2019-01-26 22:29:02      阅读:211      评论:0      收藏:0      [点我收藏+]

1.使用Array.prototype.slice.call();

Array.prototype.slice.call({
0:"yeluosen",
1:12,
2:true,
length:3
});
//["yeluosen", 12, true]

 

2.使用[].slice.call()

[].slice.call({
0:"yeluosen",
1:12,
2:true,
length:3
});
//["yeluosen", 12, true]

 

3.使用ES6中Array.from方法

Array.from({
0:"叶落森",
1:18,
2:2014,
3:"北京邮电大学",
length:4
});
//["叶落森", 18, 2014, "北京邮电大学"]

伪数组如何转成数组

原文:https://www.cnblogs.com/webjl/p/10325063.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!