Le 10/07/2013 14:48, Claude Pache a écrit :
Le 10 juil. 2013 à 11:26, David Bruant <[email protected]> a écrit :

Hi,

I was wondering whether it was any useful to have the thisArg argument in 
Array#find and Array#findIndex.
As of ES6, the language has Function.prototype.bind and arrow functions and I 
would imagine these to be enough to cover any use case where thisArg would be 
used.

I know that in the majority of cases I have experienced, there is no need for a 
specific 'this' at all. In the majority of the remaining cases arrow functions 
would have been enough. I guess .bind can do the job find for the remaining 
0.1% after that...

David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

* Consistency with every other Array methods that takes a predicate as first 
argument, and thisArg as second argument (map, filter, every, etc.).
I can't find it anymore, but I read a message from Mike Shaver (I think it was him) saying that these methods have been standardized after SpiderMonkey implementation without other form of rationale.
Who needs this particular consistency anyway?

* You can use Array#find (and Array#filter, Array#every, ...) now (with a 
polyfill), but you have to wait, say, six years until you can use arrow 
functions on the web (until non-ES6 browsers are dead).
I've been using arrow functions for the last 2 weeks with TypeScript. True story :-) Note that even if you don't want to use the whole type infrastructure, you can always use TypeScript to get most of ES6 sugar (if the compiler raises type errors, you can ignore them: js files are outputted anyways)

Meanwhile, using "this" as second argument is the most concise and most elegant 
way to simulate arrow functions.
".bind(this)" is barely less concise. I have no opinion on elegancy in this case.

David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to