ES6 - Use Arrow Functions to Write Concise Anonymous Functions

Tell us what’s happening:
I understand the concept of the topic but I don’t know the reason there is a “new” code in here, can someone please explain?

Your code so far

const magic = () => new Date()

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: ES6 - Use Arrow Functions to Write Concise Anonymous Functions

Link to the challenge:

The new keyword here creates a new instance of the date object being called then your function returns the result of that call.
Here’s a useful link.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.