stubArray()
stubArray():
unknown[]
Returns an empty array.
DEPRECATED
Use an inline arrow function () => [] instead.
Returns: unknown[]โ
An empty array.
Sinceโ
2.0.0
Also known asโ
stubArray (Lodash, es-toolkit) ยท โ (Remeda, Radashi, Ramda, Effect, Modern Dash, Antfu)
Exampleโ
// โ Deprecated approach
stubArray(); // => []
// โ
Recommended approach
(() => [])(); // => []
How it works?โ
Returns an empty array.
Deprecated: Use () => [] directly.
Native Equivalentโ
// โ stubArray
// โ
() => []
Use Casesโ
Return empty array ๐โ
Return empty array as default.
const getItems = () => [];
Default factoryโ
Use as default value factory.
const cache = new Map<string, string[]>();
function getOrCreate(key: string) {
if (!cache.has(key)) cache.set(key, []);
return cache.get(key)!;
}