_.bindAll(object, methodNames)
Binds methods of an object to the object itself, overwriting the existing method.Note: This method doesn't set the "length" property of bound functions.
Since
0.1.0
Arguments
object
(Object): The object to bind and assign the bound methods to.methodNames
(…(string|string[])): The object method names to bind.
Returns
(Object): Returns object
.
Example
var view = {'label': 'docs','click': function() {console.log('clicked ' + this.label);}};_.bindAll(view, ['click']);jQuery(element).on('click', view.click);// => Logs 'clicked docs' when clicked.
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .