From 2498bccb500f34b7549e52fb268177d6794d9b60 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 22 Mar 2011 10:44:07 -0400 Subject: [PATCH] changing order of operations to force an errror when _.bind -ing null or undefined values. --- underscore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/underscore.js b/underscore.js index c627740a0..00f6c26f5 100644 --- a/underscore.js +++ b/underscore.js @@ -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)));