HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
tc39
proposal-bind-operator
Web Development2015–2023
tc39 / proposal-bind-operator

proposal-bind-operator

This-Binding Syntax for ECMAScript

11Distinct people
12Mentions
0Explicit recommenders
1.8KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

This-Binding Syntax for ECMAScript

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 12:54:37 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year12 dated mentions

Observed mentions: 2015-06-12 17:28:02 UTC to 2023-01-20 16:07:31 UTC.

01232015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC303
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC211
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC303
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC101
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101

What Hacker News says

12 sources
There was also a different proposal that allows objects to be extended: https://github.com/tc39/proposal-bind-operator Personally, I don't use classes much, but sometimes I think free functions are a little too hard to find, so I tend to experiment with the following pattern. interface User { … } const User = { rename(user: User, newName: string): User { … }, getDisplayName(user: User): string { … } } const renke: User = { … } console.log(User.getDisplayName(renke)); Which makes finding an operation for a certain type easier to find (just write User and trigger autocomplete). The alternative is of course having renameUser (or userRename) and getUserDisplayName (or userGetDisplayname). The prefixed version would make autocomplete easier also.
In Pipe Operator (|>) For JavaScript
The author mentions iterator helpers [1], which could make stuff easier. However, there is also a different proposal that touches different similar issue which might fix this too: The bind operator proposal [2]. Like the name implies, it allows to set the `this` for a function call. This opens the possibility to implement the common map/filter/reduce functions in a lazy manner _for arrays_. Taken from the samples, this could evaluate lazily on an array returned by `getPlayers()`. import { map, takeWhile, forEach } from "iterlib"; getPlayers() ::map(x => x.character()) ::takeWhile(x => x.strength > 100) ::forEach(x => console.log(x)); Of course, this could also be used for iterators. However, the binding operator is not very active any more. [1]: https://www.proposals.es/proposals/Iterator%20helpers [2]: h
Read the rest
In Why would anyone need JavaScript generator functions?
No, there aren't two callable types in JavaScript. Thats precisely the point. Every single function has a `this` argument: function f() { return this + 5; } But there are only two ways to call it: f.call(5) // calls with `this` argument set to 5 and let x = new Number(5) x.f = f; x.f(); // syntax sugar for to x.f.call(x) The confusing part here is that `x.f()` is very different from `x.f`, and is most definitely NOT the same as `(x.f)()`, but more of an `(x.f).call(x)` Other than that and the fact that the argument is always there even if you don't specify it, its exactly the same as Lua, metatables (prototypes) and all. To resolve this confusion once and for all, we desperately need the bind operator [1] to provide a primitive on top of which the rest can be explained. [1]: https://github.com/tc39/proposal-bind-operator
In When I use classes, when I don’t, what I do instead and why
Because I said left to the dot at "call time". More succintly: > When you call a function, whatever is left of the dot is passed as the `this` argument The analogy is pretty good - you can't pass an argument to a function until you actually call it. In your example, the function hasn't been called yet, so no argument has been passed. foo.doStuff // <-- syntax to access a field member foo.doStuff() // syntax to call a field member with a `this` argument passed left of the dot. Furthermore, on the receiving side, the setTimeout function is seeing: function setTimeout(fn, delay) { // just fn, but not the argument. } Which makes it clear that you can no longer call that function with the proper `this` argument. My point was that `this` is only as confusing as you make it, and there is a simple and straightforward way to teach
Read the rest
it (function argument). If you do that, the dozens of seemingly special cases go down to just a couple. Its unfortunate we don't yet have the bind operator https://github.com/tc39/proposal-bind-operator If we had it, the explanation could be made even clearer. You would be able to call free-standing functions with a `this` argument left of the double colon, i.e. `thisArgument::freeStandingFunction()` - then the dot method call syntax `thisArgument.method()` could be explained as a syntax sugar for `thisArgument::(thisArgument.method)()` - a syntax sugar to at the same time access a function attached as a member field of an object and call it with that object as the `this` argument. The bind operator would make all those other `this` cases seem less special too. Of course you can call various bits of code with whatever `this` argument you want. The event handler code? `someElement::eventHandlerCode(event)`. A constructor? `Object.create(constructor.prototype)::constructor()`. Nothing special here, just a function argument, can have different values in different functions, depending what was passed as `this`. Its bizarre that this operator got stuck in stage 0 and is being subsumed by the pipeline operator (a terrible match for JavaScript). Looks like TC39 isn't interested in untangling the mess.
In When I use classes, when I don’t, what I do instead and why
I like this a lot. It's similar to the proposed function bind syntax[1], but a bit more friendly to not-`this`-related use: function bindMap(fn) { return this.map(fn) } [ 1, 2, 3 ]::bindMap(n => n + 1) // standalone use: bindMap.call(arr, fn) function pipelineMap(fn) { return arr => arr.map(fn) } [ 1, 2, 3 ] |> pipelineMap(n => n + 1) // standalone use: pipelineMap(fn)(arr) (Also nice that it works in a very similar way to decorators, although they won't be interchangeable in most cases, with decorators working on class constructors and property descriptors, instead of just any value.) Presumably, at most one of these proposals will make it in :) [1]: https://github.com/zenparsing/es-function-bind
In ES7 Proposal: The Pipeline Operator
Happy to help! Yes, you can use just simple function references, e.g. you could just define flatten as so function * flatten () { for ( const item of this ) { yield * item; } } And it would work just like it was part of Trine - in fact that's probably how it's going to be implemented in Trine. The chaining is not a feature of Trine, but the function bind syntax proposal ( https://github.com/zenparsing/es-function-bind ), Trine has merely been designed to work well with this syntax.
In Trine – A utility library for functional programming in JavaScript

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.