快速创建一个数组的方法

mac2022-06-30  22

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);

备注:

 

转载于:https://www.cnblogs.com/pengfei25/p/8487287.html

最新回复(0)