Pattern. Common when initializing groups or columns.
Compatibility
Browser & Runtime Support
_.stubArray is a Lodash Util helper since 4.13.0. It runs anywhere Lodash 4.13+ / 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.13.0+
_.stubArray()
Available in [email protected] full builds and the lodash/stubArray modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.13+
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.stubArrayLodash 4.13.0+
Bottom line: Safe for production once Lodash 4.13+ is loaded. Prefer import stubArray from "lodash/stubArray" for smaller bundles. Each call returns a new empty array—safer than _.constant([]) when results may be mutated.
Frequently Asked Questions
_.stubArray() takes no arguments and returns a new empty array ([]). Each call creates a fresh array instance.
They behave the same. _.stubArray is a named Lodash helper—handy as a default callback, with _.times, or when an API expects a function reference.
_.constant([]) always returns the same array reference. _.stubArray() returns a new [] every time—safer when callers might mutate the result.
No. Official docs: arrays[0] === arrays[1] is false because each call allocates a new array.
Use it as a default empty-array factory, a no-op list producer in maps/times, or a placeholder callback that must return an array type.
Yes. Any arguments are ignored—the return is always a new empty array.