Creates a new array where each element is the resolved result of the provided asynchronous callback.
The callback will be invoked once for each index from 0 to length - 1.
If no length is provided, a single-element array will be produced.
The awaited return type of the callback that becomes the type of the array items.
An asynchronous function invoked with the current index.
Optionallength: numberThe desired length of the resulting array.
A Promise resolving to an array of the callback results.
Creates a new array where each element is the result of the provided synchronous callback.
The callback will be invoked once for each index from 0 to length - 1.
If no length is provided, a single-element array will be produced.
The return type of the callback that becomes the type of the array items.
A synchronous function invoked with the current index.
Optionallength: numberThe desired length of the resulting array.
An array of the callback results.
Creates a new array where each element is the result of the provided callback.
If the callback returns at least one Promise, the entire result will be wrapped in a
Promiseand resolved withPromise.all. Otherwise, a plain array is returned.Template: ItemType
The return type of the callback (awaited if any items are a Promise) that becomes the type of the array items.
Param: callback
A function invoked with the current index. May return a value or a Promise.
Param: length
The desired length of the resulting array.
Returns
An array of the callback results, or a Promise resolving to one if the callback is async.