PSA announcement because SO MANY people don't know this, and give the horrible advice to "use arrow methods all the time problem solved": Arrow methods on ES6 classes are compiled down to bind-on-instantiation statements under the hood: github.com/facebook/react…
Mattias do I get it right and we talking about -> how transpilators are converting that into standard JS? Class properties are not yet in browsers, so we do not have any native implementation, what do we have is Babel or TypeScript which compiles it into .bind as it has no choice
I'm pretty sure engines would have to do the same, due to how JS works, but not entierly sure.
I wonder what happens with all the arrow functions that we use in array methods and all around the place - is there any performance hit?
Those are generally very simple and easy for the complier to optimize. But you should refrain from accessing the encompassing closure if there is a reasonable alternative solution.
If they get compiled to bind-on-instantiation methods, why is it bad advice to just use arrow methods all the time? Seems like a justification for that advice, if anything.
If you bind every single method I think that a factory function offers much more power and simplicity. The only reason not to use factories is because they create new functions on every instantiation, otherwise they are incredible.
I don't know if any specific version of babel did bind methods in constructor, but on my watch, babel moves the function into constructor entirely babeljs.io/repl#?babili=f…
I'm always think, that fat arrows not for using everywhere. General goal of arrows is to simplify anonymous expressions in lambda style and must be as pure as they possible. but the temptation not to follow the context is so great that everyone forgets about the true purpose
United States Trends
- 1. #AcousticPianoSnowGlobe 1,137 posts
- 2. #NXXT_NEWS N/A
- 3. #TSTheErasTour N/A
- 4. Nano Banana Pro 7,885 posts
- 5. Dick Cheney 10.2K posts
- 6. #WeekndTourLeaks N/A
- 7. FINAL DRAFT FINAL LOVE 161K posts
- 8. #LoveDesignFinalEP 145K posts
- 9. YOYOK N/A
- 10. Good Thursday 37.7K posts
- 11. Nnamdi Kanu 124K posts
- 12. Haymitch 11K posts
- 13. sohee 35K posts
- 14. Pablo 66K posts
- 15. The Hunger Games 81.7K posts
- 16. Happy Friday Eve N/A
- 17. Reaping 71.9K posts
- 18. Ray Dalio 2,478 posts
- 19. Unemployment 29.2K posts
- 20. Crockett 69.4K posts
Something went wrong.
Something went wrong.