-1

Was just wondering in Javascript, what's the difference between having two formats for class methods like so:

handleClick = (ev) => {
   ...
}

handleClick() {
 ...
}

Is there any difference at all aside from hoisting? Memory footprint, or scope, or performance?

This question is not about howto pass functions along as props in React. This specifically if I am planing to use my functions inside the class itself like this.calculateSomething();

Alexus
  • 942
  • 7
  • 20
  • I disagree. The question above is about passing functions as props to react components. Imagine I don't even use react, just vanilla JS, I am still using a class and I want to know if there is any difference when I am using functions inside the class. – Alexus Nov 28 '19 at 23:05
  • The only difference is that class variables can be lambda functions which means they don't have context. Class methods do have context. – apokryfos Nov 28 '19 at 23:07
  • 1
    @Alexus read the answers carefully, they address every use-case (props, class property handlers, etc). – Emile Bergeron Nov 28 '19 at 23:08

1 Answers1

-2

As far as V8 is concerned there is no benefits related to performance.Just the different syntax