Thanks. Your statement was tested and your definitely right. However, there might be scenarios where people want to access it outside the scope. But in case of best practice, it is always a good idea to keep things separate from the global environment. In addition, another great practice if you don’t want someone to change your variable within the scope, use const instead, and then let to change it.

Software Engineer sharing interesting tech topics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store