Arrow function vs normal function
🏷️ Javascript
Arrow function
- Can omit parentheses for single-parameter functions
- Curly braces and
returncan be omitted if the body contians a single expression - Inherit
thisfrom the enclosing scope - Does not have
argumentsobject. Use rest parameters - Cannot be used as constructor functions
- Cannot be hoisted
Normal function
thisreferes to the object that owns the function- Has
argumentsobject containing function arguments - Can be used as constructor functions with the
newkeyword - Can be hoisted