As someone who doesn't really use JavaScript much, what was wrong with the function declaration form and why are the rest needed? I learned JS before the newer ways existed and never really kept up.
When function is a statement, it has the same binding rules as var. When it is an expression, a name is optional but if it is provided it is scoped to the function body. The fat arrow operator is just like a function expression accept it does .bind(this) at the end and can have an expression instead of a code block for a body.
JavaScript has a lot of warts, but the way it lets one sling functions around …. I just love it.
38
u/damnNamesAreTaken Apr 14 '24
As someone who doesn't really use JavaScript much, what was wrong with the function declaration form and why are the rest needed? I learned JS before the newer ways existed and never really kept up.