var arr1 =30; var arr2 = new Array(arr1); for(var i=0;i<arr1.length;i++){ arr2[i] = i+1; } console.log(arr2);