function mArr(){ var arr = []; for (var i= 0, l = 4; i<l ;i++) { arr[i]= data; console.log(arr) } return arr; } mArr();