What is the difference between arrow and normal functions in JavaScript?
The main differences between arrow function and normal function are based on some parameters like.
- Syntax
- No duplicates of identified parameters.
- "this" keyword is used to describe the use.
- Utilizing a keyword that is new.
- Arguments that are binding.
Syntax of normal functions
// Function declaration
function printHello(name) {
return `Hey ${name}`;
}
NOTE: If you want to read more about Regular vs Arrow functions then you can visit here.
// Function expression
const printHello = function(name) {
return `Hey ${name}`;
}
Syntax of arrow functions
const printHello = (name) => `Hey ${name}`;
BY Best Interview Question ON 12 Sep 2022