Right now, when you have to make an array of identical values of some size, there are a few ways to do it:
'use strict';
const arr = [];
for (let idx = 0; idx < 32; idx++) {
arr[idx] = 0;
}
this approach is a little better:
'use strict';
const len = 32;
const arr = new Array(len);
for (let idx = 0; idx < len; idx++) {
arr[idx] = 0;
}
In most cases, we have to iterate through each entry in the array and manually set it, even if the entries within the array all have identical values at their initial setting.
Iβm proposing that, in addition to allowing the current approaches, we add Array.massMake(), which could work like this:
'use strict';
const len = 32;
const allInitialValues = 0;
const arr = Array.massMake(len, allInitialValues);
This would simplify and reduce code. There might be some performance improvements resulting from this, but that would depend on the implementation from the runtime engine. Iβm merely proposing this for the code reduction and simplification.
Also, if someone has a better name than Array.massMake(), please note it in the comments.