How to use the functions function from underscore

Find comprehensive JavaScript underscore.functions code examples handpicked from public code repositorys.

934
935
936
937
938
939
940
941
942

// Bind all of an object's methods to that object. Useful for ensuring that
// all callbacks defined on an object belong to it.
_.bindAll = function(obj) {
  var funcs = slice.call(arguments, 1);
  if (funcs.length == 0) funcs = _.functions(obj);
  each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
  return obj;
};
fork icon0
star icon0
watch icon1

+ 6 other calls in file

8967
8968
8969
8970
8971
8972
8973
8974
8975

// Bind all of an object's methods to that object. Useful for ensuring that
// all callbacks defined on an object belong to it.
_.bindAll = function(obj) {
  var funcs = slice.call(arguments, 1);
  if (funcs.length === 0) funcs = _.functions(obj);
  each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
  return obj;
};
fork icon0
star icon0
watch icon1

+ 2 other calls in file