1 export const ArrayFun
= {
3 // Double array intialization
4 init: function(size1
, size2
, initElem
) {
5 return [...Array(size1
)].map(() => Array(size2
).fill(initElem
));
9 return [...Array(max
).keys()];
12 toObject: function(keys
, values
) {
13 if (!Array
.isArray(values
))
14 // Second argument is a scalar
15 values
= Array(keys
.length
).fill(values
);
17 ArrayFun
.range(keys
.length
)
18 .reduce((acc
, curr
) => (acc
[keys
[curr
]] = values
[curr
], acc
), {})