Lodash _.once() Method
The _.once() method of Function in lodash is used to create a function which can call func parameter of this method only once. However, repeated calls to this function will return the value returned in the first call.
Note: The func parameter of this method is called with this binding along with the arguments of the created function.
Parameters: This method accepts a single parameter which is described below:
- func: It is the function which is to be restricted.
Return Value: This method returns the new restricted function.
Logged in to the console!
Here, hold is called multiple times but only the value of first call is returned as you can call func only once as stated above.
Here, each time the fetch is called the same value is returned as returned to the first call.
Please Login to comment...