(note, it couldn't be a direct proxy to `bind` because `bind(null)`
permanently sets the "this" value (ie, `(function () { return this
}).bind(null).call([])` will return null or the global object, not the
empty array. the polyfill would be a bit trickier, and couldn't use "bind"
under the hood without changes to bind itself)On Sun, Oct 4, 2015 at 8:06 AM, Tim Ruffles <[email protected]> wrote: > It'd be nice to add Function.prototype.partial, which is exactly like > `.bind` without the `this`-setting first argument. > > Adding it would have benefits: > > - `.bind(null, ...` is newbie confusing and ugly in functional code[1] > - `.bind(null, ...` is a very common idiom[2] > - `.partial` is intention revealing: it's clear you're writing functional > code that doesn't care about `this` > > Adding it seems low cost, and is backwards compatible: > > - implementors could literally make it a proxy to `.bind` if they want to > get it done fast > - shimmable > - not new functionality, just a subset of existing functionality > > Cheers, > > Tim > > @timruffles > > - [1] I've been teaching newbies Javascript/Node.js for years, and if you > take a 'functions first' approach it's complexity you have to tell them to > ignore > - [2] see github - > https://github.com/search?l=javascript&q=%22.bind%28null%22&ref=searchresults&type=Code&utf8=%E2%9C%93 > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

