DEV Community

Cover image for Difference between Traditional function and Arrow function?
Arul .A
Arul .A

Posted on

Difference between Traditional function and Arrow function?

TRADITIONAL FUNCTION:

  • The function is a block of code and it is used to perform a specific task.

  • Traditional functions have their own this, can be used as constructors, and have arguments.

  • It contains function keyword, function name, and followed by parenthesis and curly brackets.

Example:

  function name(){
console.log("Arul")
}
name()

Enter fullscreen mode Exit fullscreen mode

ARROW FUNCTION:

  • It is also block of code ,It reduces the code length.

  • Arrow functions don’t bind this, cannot be constructors, and don’t have arguments.

  • It not contains function keyword, function Name.

Example:

const arrow=()=>console.log("Arul")
arrow()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)