1function zeros(dimensions) {
2 var array = [];
3
4 for (var i = 0; i < dimensions[0]; ++i) {
5 array.push(dimensions.length == 1 ? 0 : zeros(dimensions.slice(1)));
6 }
7
8 return array;
9}
10
11> zeros([5, 3]);
12 [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
13