javascript function syntax arrow no parameters code example
Example 1: Arrow Functions
// The usual way of writing function
const magic = function() {
return new Date();
};
// Arrow function syntax is used to rewrite the function
const magic = () => {
return new Date();
};
//or
const magic = () => new Date();
Example 2: arrow func in javascript
const greet = (who) => {
return `Hello, ${who}!`;
};
greet('Eric Cartman'); // => 'Hello, Eric Cartman!'