Conventions around JS hoisting?

I’m reading this: Callback Hell
Somewhere it reads -

  1. Use function hoisting to your advantage to move functions ‘below the fold’

Up to this point I was under the impression that hoisting should be avoided, but is function hoisting an exception?

Different codebases have different rule on structure, and the important thing to do is to have a consistent structure throughout your codebase. Personally I don’t often make use of hoisting, but you just gotta go with the flow because that literally helps things flow.

2 Likes

Personally, I’m not wild about hoisting functions.

Modularizing code is great and important, but I find it much clearer to define a function before you use it. Modularizing does not require hoisting.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.