JavaScript scope

JavaScript Scope

A collection of scope accessible variables.

JavaScript scope

In JavaScript, objects and functions are also variables.

In JavaScript, scope is a collection of accessible variables, objects, and functions.

JavaScript function scope: The scope is modified within the function.

JavaScript local scope

Variables are declared within the function, and the variables are local scope.

Local variables: can only be accessed inside the function.

  局部变量在声明的函数内可以访问。myFunction();
document.getElementById("demo").innerHTML =
"我的名字叫 " +  typeof Name;
function myFunction() 
{
    var Name = "jack";
}
Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <p>局部变量在声明的函数内可以访问。</p> <p id="demo"></p> <script> myFunction(); document.getElementById("demo").innerHTML = "我的名字叫 " + typeof Name; function myFunction() { var Name = "jack"; } </script> </body> </html>
submitReset Code