changing order of operations to force an errror when _.bind -ing null or undefined values.

This commit is contained in:
Jeremy Ashkenas
2011-03-22 10:44:07 -04:00
parent c5ba702542
commit 2498bccb50

View File

@@ -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)));