JavaScript: Change function declarations to expressions at legacy code

137 Views Asked by At

I'm refactoring legacy code. I can see that for functions used both declarations and expressions. I know that declarations are hoisted, expressions work as step-by-step execution. There are also named function expressions but I can't use them because there are problems with IE8. So, my question is:

Can I just replace all function declarations with expressions? Is there any visible or possible problems with such replacement? I want to use expressions, define them at top of the file.

1

There are 1 best solutions below

3
On

Why would you want to use expressions? Declarations provide benefit of seeing function name in the produced error stacktrace (Which you will not if you use expression with anonymous function), also you may experience problem with recuriosn if you use expressions.