const holidays = () => return "Merry Christmas and a happy new year 😀!"
In this example you dont really need word "return". Arrow functions which are one line and dont use curly braces automatically return result. So it should be like this:
const holidays = () => "Merry Christmas and a happy new year 😀!"
Thanks for the info. Looking for the continuation. Small note: I think there is a typo for your first example Object methods. You mention "the property post.claps would increase by one". However, there is not property "claps" in the code example. There is "likes" though.
At any rate, good stuff here and thanks again for posting.
I'm Calin Baenen – AKA KattyTheEnby – a programmer born October 30th, 2006. I love programming, it has been my passion since I was a kid, and will forever be my passion.
I'm Calin Baenen – AKA KattyTheEnby – a programmer born October 30th, 2006. I love programming, it has been my passion since I was a kid, and will forever be my passion.
const holidays = () => return "Merry Christmas and a happy new year 😀!"
In this example you dont really need word "return". Arrow functions which are one line and dont use curly braces automatically return result. So it should be like this:
const holidays = () => "Merry Christmas and a happy new year 😀!"
I wanted to be more clear. But yours also works well.
Usage of
return
explicitly into a single statement arrow function (without the curly brackets), is actually a syntax error 🙁.I also changed it lol.
Thanks for the info. Looking for the continuation.
Small note: I think there is a typo for your first example Object methods. You mention "the property post.claps would increase by one". However, there is not property "claps" in the code example. There is "likes" though.
At any rate, good stuff here and thanks again for posting.
ohhh I didn't catch that. Thanks for correcting
Actually, you said arrow functions don't have arguments.
That is false.
You can read it from here:
developer.mozilla.org/en-US/docs/W...
Oh, you meant the keyword (you should probably specify that in the post).
Yeah, I just added it now.
As far as your first point, that's literally just syntax sugar/shorthand for a regular
function
declaration.Great article. Thanks 🙂
For object methods, you should use the "like() {}" syntax
That's a good one.
cool stuff! Actually, I didn't know this 😍(before reading this post)
Glad it helped 😁
Please replace "why" with "when" in your post as it is very misleading, thanks.