0 votes
in JavaScript by
What are the benefits of keeping declarations at the top?

1 Answer

0 votes
by

It is recommended to keep all declarations at the top of each script or function. The benefits of doing this are,

  1. Gives cleaner code
  2. It provides a single place to look for local variables
  3. Easy to avoid unwanted global variables
  4. It reduces the possibility of unwanted re-declarations
...