Arrow functions - they're the more concise version of regular functions and they've been gaining popularity since they were first introduced in ES6...
For further actions, you may consider blocking this person and/or reporting abuse
The lexically bound
this
context is probably the most important quality of thicc arrow functions.Agreed. It helps with some of the strange and unexpected behavior of
this
.Being a react developer, I mostly use arrow functions to bind this context
You are not binding the context by using an arrow function, it doesn't work that way.
More info here: github.com/getify/You-Dont-Know-JS...
I tend to use hooks in new code and avoid
this
altogether.Can you please provide an example of this (using hooks not
this
).why would you need
this
when you don't use classes.Sorry I'm just confused what you mean by hooks. Hoping you might paste in an example?
Classical React example of Counter
and after using React Hooks
know more about react hooks.
Implicit return:
When returning an Object, remember to wrap the curly brackets in parentheses to avoid it being considered the default wrapping function body brackets:
And remember to write tests so you catch these mistakes :)
We wish to read you about tests - from scratch - if you have time to start a serie about that topic... ;)
When I first saw the Title and I thought it is going to be something strange but it came out as the Lambda Functions that is being used in the Higher Versions of Java, by the way as I am a JavaScript Developer as well so it is very nice post according to that as well :)
The arrow function is by definition a lambda function, is not just syntax.
Concise and easy to understand, love learning little new bits and pieces about JS!
The
this
keyword has shortened my coding time by a lot in my recent projects.Thank you!
Hi Kara I think there's a missing
const
in the very first snippet :-)Ah thank you! I meant to get rid of setting that variable at all actually.
Great post! Also really appreciate the link to a deeper insight of how the keyword works with arrow functions.👌
A nice quick read with usefull information. I didn't know it does an implicit return. I'm still not sure how
this
works, but I'll look that up.Thanks!
Thank you!
Nice post! Truly helpful as I never took the time to truly master the arrow function
Nice write up, Kara.
Thank you!
How do we write a return type in an arrow function?
Arrow functions make more sense to me know that I know about hashes in Ruby 🤔