Lodash _.stubArray() Method
Last Updated :
03 Nov, 2023
Lodash _.stubArray() method is used to create a new empty array.
Syntax:
_.stubArray();
Parameters:
This method does not accept any parameters.
Return Value:
It returns a new empty array.
Example 1: In this example, we are getting the empty array by the use of the lodash _.stubArray() method.
Javascript
const _ = require( "lodash" );
let arr = _.stubArray();
console.log(arr);
|
Output:
[]
Example 2: In this example, we are getting the empty array by the use of the lodash _.stubArray() method.
Javascript
const _ = require( "lodash" );
let arr = _.times(5, _.stubArray);
console.log(arr);
|
Output:
[ [], [], [], [], [] ]
Share your thoughts in the comments
Please Login to comment...