What’s different using
const functionName = () => {};
or
function functionName() {};
to declare a function
Often it’s largely stylistic (arrow functions tend to be more compact).
But they do have real differences in functionality (no pun intended!), see the docs for a list: Arrow function expressions - JavaScript | MDN
1 Like
Is there any situation that we could not use var to declear a variable but must use const ?
Hi,
I think in js var
is a bit outdated, now people seem to use let
.
As for const
, it’s good style to use it when appropriate. It ensures code safety and better readability.
1 Like
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.