Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives.
func
this
thisArg
partials
The bind.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for partially applied arguments.
bind.placeholder
_
Note: Unlike native Function#bind, this method doesn't set the "length" property of bound functions.
Function#bind
The function to bind.
Optional
The this binding of func.
The arguments to be partially applied.
Returns the new bound function.
5.3.0
function greet(greeting, punctuation) { return greeting + ' ' + this.user + punctuation;}var object = { 'user': 'fred' };var bound = bind(greet, object, 'hi');bound('!');// => 'hi fred!'// Bound with placeholders.var bound = bind(greet, object, _, '!');bound('hi');// => 'hi fred!' Copy
function greet(greeting, punctuation) { return greeting + ' ' + this.user + punctuation;}var object = { 'user': 'fred' };var bound = bind(greet, object, 'hi');bound('!');// => 'hi fred!'// Bound with placeholders.var bound = bind(greet, object, _, '!');bound('hi');// => 'hi fred!'
placeholder of bind function
Creates a function that invokes
func
with thethis
binding ofthisArg
andpartials
prepended to the arguments it receives.The
bind.placeholder
value, which defaults to_
in monolithic builds, may be used as a placeholder for partially applied arguments.Note: Unlike native
Function#bind
, this method doesn't set the "length" property of bound functions.