πŸ’Functions

function sayHello(username) {
  console.log(`Hello ${username}`);
}

sayHello("HuXn"); 
// Function Expressions
const greetings = function (user) {
  console.log(`Hello ${user}`);
};

greetings("Doe");

JavaScript Arrow Function

// ----- Normal Function -----
let x = function(x, y) {
   return x * y;
}

can be also used as

// ----- Arrow Function -----
let x = (x, y) => x * y;
// ----- Arrow Function -----
const greet = (username) => {
   return `Hello ${username}`
}

console.log(greet("mridul"));

Last updated