Day #9 Pro Tip #Javascript

Block level scope in Javascript !!!

Arwa Lokhandwala
Geekabyte
1 min readApr 10, 2018

--

Let us consider this example

This happens because unlike other languages which have default block level scope Javascript doesn’t provide that. But no worries there is a way to have block level scope of the variables using let keyword for variable declaration. So block level scope in the above example can be achieved in the following way

Thanks for reading :)

Stay tuned for more updates !!!

--

--