4.17.11
3.10.1
2.4.2
1.3.1

_.once(func)

Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. The func is invoked with the this binding and arguments of the created function.

Since

0.1.0

Arguments

argument
func
type
Function
description
The function to restrict.

Returns

(array)

Example

var initialize = _.once(
  createApplication
);
initialize();
initialize();
// => `createApplication` is invoked once
var initialize = _.once(createApplication);
initialize();
initialize();
// => `createApplication` is invoked once