快速创建一个数组的方法

1、根据12创建一个12个“-”的数组

(new Array(12).join("-;")+"-").split(";"); 

2、根据12创建12个月份的数组【“1月”。。。。“12月”】

var arr5 = Object.keys(Array.apply(null, {length:12})).map(function(item){       
    return +(parseInt(item)+1)+"月";   
});
console.log(arr5);

备注:

 

posted @ 2018-03-01 10:43  人在路途  阅读(526)  评论(0)    收藏  举报