Advance JavaScript Course
About Lesson

Arrow functions, or Fat arrow functions, are a new way to create functions in ECMAScript 6. Arrow functions simplify function syntax. They are called fat arrow functions because they are denoted with the characters =>, which, when put together look like a fat arrow. Arrow functions in JavaScript are frequently used in callback chains, promise chains, array methods, in any situation where unregistered functions would be useful.

Arrow function {()=>} is concise way of writing JavaScript functions in shorter way. Arrow functions were introduced in the ES6 version. They make our code more structured and readable.

Arrow functions are anonymous functions i.e. functions without a name but they are often assigned to any variable. They are also called Lambda Functions.

Syntax:

const gfg = () => {
console.log( “Hi Geek!” );
}

Advantages of Arrow Functions:
  • Arrow functions reduce the size of the code.
  • The return statement and function brackets are optional for single-line functions.
  • It increases the readability of the code.
  • Arrow functions provide a lexical this binding. It means, they inherit the value of “this” from the enclosing scope. This feature can be advantageous when dealing with event listeners or callback functions where the value of “this” can be uncertain.
Limitations of Arrow Functions:
  • Arrow functions do not have the prototype property.
  • Arrow functions cannot be used with the new keyword.
  • Arrow functions cannot be used as constructors.
  • These functions are anonymous and it is hard to debug the code.
  • Arrow functions cannot be used as generator functions that use the yield keyword to return multiple values over time.
Exercise Files
No Attachment Found
No Attachment Found
Join the conversation

Introducing Official ApeStaking Protocol for ApeCoin.

New Blur NFT Marketplace Courting Professional.