Arrow Functions in Class Properties Might Not Be As Great As We Think

Comparison between without (left) and with (right) class properties.
Usage example of arrow function in a class property.

What Class Properties look like once transpiled to ES2017

Mockability

Inheritance

Performance

Conclusion

The initialization of arrow functions in class properties are transpiled into the constructor.

Arrow functions in class properties won’t be in the prototype and we can’t call them with super.

Arrow functions in class properties are much slower than bound functions, and both are much slower than usual function.

You should only bind with .bind() or arrow function a method if you’re going to pass it around.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store