码迷,mamicode.com
首页 > 编程语言 > 详细

javascript快速产生数组方法

时间:2017-07-16 14:17:19      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:快速   nbsp   array   join   code   item   index   span   style   

//生成[item1-item9]数组
Array(9).join(0).split(‘‘).map((item,index) => ‘item‘ + (index+1))

//生成20个对象的数组
Array.apply(null,{length:20}).map(function(item,index){
    return {name:‘xxx‘,index:(index+1)};
});

 

javascript快速产生数组方法

标签:快速   nbsp   array   join   code   item   index   span   style   

原文地址:http://www.cnblogs.com/mengff/p/7190340.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!