DEV Community

Cover image for Reading Snippets [55 => Scoping]
Calvin
Calvin

Posted on

Reading Snippets [55 => Scoping]

It is important to try and avoid scope pollution when using global variables in a program. Tightly scoping variables using the block scope provides several advantages:

๐Ÿ™‚ Makes code more legible as blocks organize code in discrete sections

๐Ÿ™‚ Makes code easier to understand

๐Ÿ™‚ Makes code easier to maintain

๐Ÿ™‚ Saves memory in code

Codecademy: JavaScript Course

Top comments (0)