Who doesn’t love the simplicity of arrow functions? Introduced as part of the ECMAScript 6, arrow functions went viral. The new syntax to declare f...
For further actions, you may consider blocking this person and/or reporting abuse
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.
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.
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
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.