Use Arrow Functions to Write Concise Anonymous Functions (new)

I tried doing this but it didn’t work:

const magic = () => Date();

The answer for this challenge is

const magic = () => new Date();

What does the ‘new’ keyword do and why is it necessary?

Thank you for the help!

new is just creating the instance of the Date object, which is returned later by the function. This part isn’t specific for the “arrow functions”, but that’s how instances of objects are created in javascript.

2 Likes

Thank you for the help!!
:heart: