Closed js-choi closed 3 years ago
Any part of node that uses the "primordials" pattern pulls in, for example, ArrayPrototypeSlice
.
With this proposal, it could name that slice
, and then do arr->slice(x, y)
instead of what it does now: ArrayPrototypeSlice(arr, x, y)
.
I'd note that primordials in node do sometimes do much more than just uncurry the this
value so it wouldn't remove the need for primordials entirely, just most of the prototype methods.
For future reference: nodejs/node#30697 and lib/internal/per_context/primordials.js.
I am seeking real-world examples of code that would be improved by a syntactic
this
-bind operator.According to @ljharb and @bmeck, Node contains many methods that bind various intrinsic global methods in order to avoid being affected by external prototype pollution. @bmeck gives this example in tc39/proposal-extensions#11:
…which in this proposal would be improved to:
Where in Node.js (or elsewhere) does this pattern actually occur? We need to transplant examples from them into the explainer.