Function.prototype.partial

Tim Ruffles oi at truffles.me.uk
Sun Oct 4 15:06:41 UTC 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151004/4e4cedd2/attachment.html>


More information about the es-discuss mailing list