Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_.bind supports _.partial application, but not its non pre-filled argument syntax with _ #2328

Majeure opened this issue Oct 26, 2015 · 5 comments


Copy link

@Majeure Majeure commented Oct 26, 2015

I don't know if this is intended behavior, but it seems all around confusing if so. My guess is this portion of _.bind was just left untouched when _.partial received this functionality. Here's the simplified reproduction of it in jsfiddle:

var foo = function(bar) {
    console.log(bar); //this should always print 'bar' if non pre-filled arguments applied to bind's partial application as well, yet it has the value of underscore when not double wrapped

_.bind(foo, this, _)('bar'); //function (n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)}
_.bind(_.partial(foo, _), this)('bar'); //bar
Copy link

@jdalton jdalton commented Oct 26, 2015

Currently Underscore only supports placeholders in _.partial.

From a feature parity perspective lodash supports placeholders in _.bind.
It may be seen as a breaking change in Underscore so might have to wait until 2.0.

Copy link

@jridgewell jridgewell commented Oct 26, 2015

I'm good with it. Note that this will invalidate the first two options in #2214 (comment).

Copy link

@megawac megawac commented Oct 26, 2015

I'd rather wait til 2.0 before anything radical is done to bind. Though we could definitely work towards 2.0/underdash soon

Copy link

@jdalton jdalton commented Oct 26, 2015

I'm cool with deferring to 2.0. We should add it to a 2.0 issue or wiki entry so it's not forgotten then close out this issue.

Copy link

@sament-sugarcrm sament-sugarcrm commented Oct 25, 2017

If you're going to defer this to 2.0, I'd recommend adding a note to the documentation. It says to check _.partial documentation for the partial application, which leads the reader to believe that _.bind also supports it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

6 participants