mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Issue #150: _.bind should allow binding functions to falsy values.
This commit is contained in:
@@ -20,10 +20,15 @@ $(document).ready(function() {
|
||||
|
||||
var func = _.bind(func, this, 'curly');
|
||||
equals(func(), 'hello: curly', 'the function was completely applied in advance');
|
||||
|
||||
|
||||
var func = function(salutation, firstname, lastname) { return salutation + ': ' + firstname + ' ' + lastname };
|
||||
func = _.bind(func, this, 'hello', 'moe', 'curly');
|
||||
equals(func(), 'hello: moe curly', 'the function was partially applied in advance and can accept multiple arguments');
|
||||
|
||||
func = function(context, message) { equals(this, context, message); };
|
||||
_.bind(func, 0, 0, 'can bind a function to `0`')();
|
||||
_.bind(func, '', '', 'can bind a function to an empty string')();
|
||||
_.bind(func, false, false, 'can bind a function to `false`')();
|
||||
});
|
||||
|
||||
test("functions: bindAll", function() {
|
||||
|
||||
@@ -412,7 +412,7 @@
|
||||
if (nativeBind && func.bind === 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)));
|
||||
return func.apply(obj, args.concat(slice.call(arguments)));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user