_.bindAll

_.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

  1. object (Object): The object to bind and assign the bound methods to.
  2. 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.
doc_Lodash
2016-11-27 16:35:40
Comments
Leave a Comment

Please login to continue.