Normal function vs Arrow function
English

Normal function vs Arrow function

by

So, what are the main differences between normal functions and arrow functions

Normal Function: Has its own this. The value of this is dynamic. it depends on how the function is called.

Arrow Function: Does not have its own this. It inherits this from the surrounding code (lexical scope).

Normal: Always requires the return keyword and curly braces {}.

Arrow: If it's a single-line expression, you can omit both the braces and the return keyword. (Implicit Return)

Normal: Can be used as a Constructor. You can call new Person() and it will create a new object instance.

Arrow: Cannot be used with new. If you try, JavaScript will throw a TypeError. They are designed to be "callable" but not "constructible."

Normal: Has access to a special arguments object, which is an array-like list of every value passed into the function.

Arrow: Does not have an arguments object. If you need to access all arguments, you must use Rest Parameters instead:

1