Understanding javascript scopes and lessons learned

One of the things when working with Javascript that gives me some headaches is how it deals with scopes. There is no magic behind that, however I found the syntax to be a bit confusing when reading the code (ex: var, let, const, global declaration), as sometimes it requires to go in ‘detail’ mode.

When talking about scopes, I like to think about it as the context of the of the line of code/variable it is running. […]