Date

“Util” Methods

_.bindAll(object, methodNames)

source npm package

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.

引入版本

0.1.0

参数
object (Object) : The object to bind and assign the bound methods to.
methodNames (...(string|string[])) : The object method names to bind.

返回值
(Object) : Returns object.

示例
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.