DEV Community

stalin s
stalin s

Posted on

Javascript arrow functions

Arrow functions are preety cool 😎 . They help you make code shorter, which gives less room for errors to hide. They also help you write code that's easier to understand once you get used to the syntax.

The Syntax.

Arrow function is denoted by (=>) . In ES6 its a new way to make anonymous function.

_ Normal function : _

const normalFunction = function (arg1, arg2) {
  // pls do something
}

Enter fullscreen mode Exit fullscreen mode

Arrow function

// Arrow Function

const arrowFunction = (arg1, arg2) => {
  // pls do something
}
Enter fullscreen mode Exit fullscreen mode

Steps to convert normal function to arrow function.

1) Remove function keyword from a normal function .
2) Add => after the parenthesis to get an arrow function.

Happy Learning

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay