Skip to content

Commit

Permalink
changing order of operations to force an errror when _.bind -ing null…
Browse files Browse the repository at this point in the history
… or undefined values.
  • Loading branch information
jashkenas committed Mar 22, 2011
1 parent c5ba702 commit 2498bcc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@
// Create a function bound to a given object (assigning `this`, and arguments,
// optionally). Binding with arguments is also known as `curry`.
// Delegates to **ECMAScript 5**'s native `Function.bind` if available.
// We check for `func.bind` first, to fail fast when `func` is undefined.
_.bind = function(func, obj) {
if (nativeBind && func.bind === nativeBind) return func.bind.apply(func, slice.call(arguments, 1));
if (func.bind === nativeBind && nativeBind) return func.bind.apply(func, slice.call(arguments, 1));
var args = slice.call(arguments, 2);
return function() {
return func.apply(obj, args.concat(slice.call(arguments)));
Expand Down

0 comments on commit 2498bcc

Please sign in to comment.