简体   繁体   中英

JavaScript: Change function declarations to expressions at legacy code

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM