differnt syntax for arrow functions 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 function

Arrow Function is another way to write a function.
"classic method":
function x ()
{
	console.log("X")
}
"arrow method":
var x= ()=>
{
	console.log("X")
}
if we need to add paramiter is pritty simple:
var x = (PARAMS) =>
{
	console.log(PARAMS)
}
Have a nice day

Tags:

Misc Example