DEV Community

Discussion on: Functions, fat arrows and parentheses

Collapse
thumbone profile image
Bernd Wechner • Edited on

I have to admit I find it odd that you start with a "typical function":

const someString = () => {
  return 'some string'
}
Enter fullscreen mode Exit fullscreen mode

when that is bizzaro to me and not typical. Sure I see it a fair bit nowadays, it's not rare per se, but it is still distinctly a neologism and maybe it's old school but this is a typical function:

function someString() {
  return 'some string'
}
Enter fullscreen mode Exit fullscreen mode

Which, hey, is reminiscent of the banner image ;-).

One of the most fun things about functions though that you've missed IMHO is the loss of this, most especially in event handlers. It's also not uncommon to use classes as a means of encapsulating and isolating closely related code. And when your event handlers are methods of a class or functions inside of methods even, this becomes a fairly hefty issue.

To wit, we commonly see .bind(this) which is one of Javascript's painful little idiosyncrasies 😉

Some comments have been hidden by the post's author - find out more