Here i am creating two dimensional array and push values into it. In this code i create empty array using for loop and again i am using forloop to push the values into an array.My question I need to create an array and push the values in an array with one time for loop.
var arr = [];
for (var tot=0;tot<4;tot++) {//creating empty arrays
arr.push([]);
}
for (var tot=0;tot<4;tot++) {//pushing values into an array
for (var i=0;i<3;i++) {
arr[tot].push(i);
}
}
console.log(JSON.stringify(arr));//[[0,1,2],[0,1,2],[0,1,2],[0,1,2]]
answer either in javascript or jquery