-1

In nodejs, functions are read and cached at the beginning of execution, so it doesn’t really matter where functions are written in a program. Is it correct that functions inside functions are also cached at this time, eg callbacks?

If so does it follow, that callbacks can also be written anywhere inside the parent function, top or bottom?

Is there a code preference that the JavaScript community takes regarding where functions in general are written and more specifically, where callback functions are written inside its parent function, eg up top or down the bottom etc.

ajhstn
  • 101
  • 1
  • 3
  • 11

1 Answers1

1

I think what you are referring to is Hoisting, hoisting is part of javascript language characteristics along side with how javascript is interpreted and executed.

You need to understand hoisting and then you will know that hoisting is related to declaration and based on that you will get the point.

Amr Labib
  • 3,995
  • 3
  • 19
  • 31