The scope of a variable implies where the variable has been declared or defined in a JavaScript program. There are two scopes of a variable:
Global Scope
Global variables, having global scope are available everywhere in a JavaScript code.
Local Scope
Local variables are accessible only within a function in which they are defined.
Leave a Reply