1 var arrayEach = require('./_arrayEach'),
2 baseAssignValue = require('./_baseAssignValue'),
3 bind = require('./bind'),
4 flatRest = require('./_flatRest'),
5 toKey = require('./_toKey');
8 * Binds methods of an object to the object itself, overwriting the existing
11 * **Note:** This method doesn't set the "length" property of bound functions.
17 * @param {Object} object The object to bind and assign the bound methods to.
18 * @param {...(string|string[])} methodNames The object method names to bind.
19 * @returns {Object} Returns `object`.
24 * 'click': function() {
25 * console.log('clicked ' + this.label);
29 * _.bindAll(view, ['click']);
30 * jQuery(element).on('click', view.click);
31 * // => Logs 'clicked docs' when clicked.
33 var bindAll = flatRest(function(object, methodNames) {
34 arrayEach(methodNames, function(key) {
36 baseAssignValue(object, key, bind(object[key], object));
41 module.exports = bindAll;