In Javascript, we have 3 types of scope: block scope, function scope and global scope. Scope defines the accessibility(visibility) of the variable, which means whether the variable is accessible or not. Before ES6 (2015), JavaScript had only Global Scope and Function Scope. I hope it helps you to understand scope in a better way.

2m read timeFrom bytecodepandit.medium.com
Post cover image
Table of contents
Let’s solve some javascript interview questionsScope in javascriptBlock scopeFunction scopeGlobal scopeAutomatically global

Sort: