Loading [MathJax]/jax/output/HTML-CSS/config.js

What is Scope in JavaScript?

Technology CommunityCategory: JavaScriptWhat is Scope in JavaScript?
VietMX Staff asked 4 years ago

In JavaScript, each function gets its own scope. Scope is basically a collection of variables as well as the rules for how those variables are accessed by name. Only code inside that function can access that function’s scoped variables.

A variable name has to be unique within the same scope. A scope can be nested inside another scope. If one scope is nested inside another, code inside the innermost scope can access variables from either scope.

Please Disable AdBlock Plus and Refresh Website