0

What is the difference between

displayFunction() {
  console.log('test')
}

and

const displayFunction = () => {
  console.log('test')
}

I code in Angular a bit and saw the first way of defining methods all the time. However, React seems to prefer the second way.

Castor troy
  • 47
  • 1
  • 5
  • check this out: https://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/ – Marouen Mhiri Dec 03 '17 at 11:24
  • the es6 function will be transpiled to this: var displayFunction = function displayFunction(){ console.log('test')} – Marouen Mhiri Dec 03 '17 at 11:25
  • see this: [https://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname](https://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname) – vibhor1997a Dec 03 '17 at 11:28

0 Answers0