Does anyone know the history behind "this"? Is there any other language that uses "this" to denote "current context"?
ECMAScript bind operator proposal
21–30 of 50 posts
Re: ECMAScript bind operator proposal
#22Earlier quoted context omitted.
I respectfully disagree. It all has to do with this line: "By providing syntactic sugar for these use cases we will enable a new class of "virtual method" library, which will have usability advantages over the standard adapter patterns in use today." Essentially, you write functions that provide a certain behavior without being coupled to a specific class, so you can have a 'map' method that is called the same way no…
Wouldn't a pipeline operator [1] be a more interesting solution for this instead of adding syntax that relies on the `this` keyword? [1] https://github.com/mindeavor/es-pipeline-operator
Re: ECMAScript bind operator proposal
#23I don't think Ecma-script needs new operators ,especially the kind of operators that will make it look like C++ , just to save a few key types. There needs to be a balance. A balance between all these tricks and readability.
Re: ECMAScript bind operator proposal
#24This proposal really deserves the "kill it with fire" label. Adding new operators to do things that are already possible will only serve to make the language more complicated and code written in JS more difficult to understand and maintain. JS's minimalism is its greatest strength.
Lua is minimal. Scheme is minimal. Forth is minimal. Hell, Brainfuck is minimal. JS isn't.
Re: ECMAScript bind operator proposal
#25It's also worth noting that most (?) modern browsers already bind log to console. At least Chrome, Firefox, and Safari all support it. I don't have a Windows machine so I can't confirm if Edge supports it. Same goes for Node.
[1, 2, 3].forEach(console.log)Re: ECMAScript bind operator proposal
#26This proposal has been around for a while. I try keeping an open mind, since I've been wrong about many other syntactic features... But I just don't see this being that useful; none of the examples seem particularly compelling. It's also worth noting that most (?) modern browsers already bind log to console. At least Chrome, Firefox, and Safari all support it. I don't have a Windows machine so I can't confirm if Edge…
And it should be in all modern browsers soon[1], as `window.console` is now a namespace: https://console.spec.whatwg.org/#console-namespace
[1]: https://developer.microsoft.com/en-us/microsoft-edge/platfor...
Re: ECMAScript bind operator proposal
#27Re: ECMAScript bind operator proposal
#28Neat! Extension methods and getting rid of "var that = this;" in one! It seems that it also extends to full expressions on the right-hand side of ::, so you can even do, for using Array operations over things that look like arrays but not quite: document.querySelectorAll('p')::([].map)(f) instead of: [].map.call(document.querySelectorAll('p'), f) (replace [].map with Array.prototype.map if it feels less gross)
This also works, by the way: [...document.querySelectorAll('p')].map(f) In the future, NodeList could extend Array which would make these workarounds redundant. Extending Array was made possible by ES6. Anyhow, I think having some kind of extension methods would be great.
It would break the web, unfortunately. (We've experimented with NodeList.prototype.__proto__ being Array.prototype instead of Object.prototype and it breaks sites, and ES6's extends notion implies that.)
Re: ECMAScript bind operator proposal
#29Re: ECMAScript bind operator proposal
#30I really wish we could stop building on top of this abomination (fake ES6 classes, binding, etc)
The |> operator (chaining of regular functions) would be so much better to program with. We don't need both.