FrontendDeveloper.in

JavaScript question detail

What are the benefits of keeping declarations at the top

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
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399