Home > Web Front-end > JS Tutorial > The function of js static scope. _Basic knowledge

The function of js static scope. _Basic knowledge

WBOY
Release: 2016-05-16 19:22:24
Original
1020 people have browsed it

The scope of JS is a relatively complicated thing

The scope of JS is static. When a function is defined, the scope of the function is the scope in which the function is defined, not the scope in which the function is called. domain.

When a function is called, a new scope will be created. The variables defined with var in this scope are local variables. Generally, the scope created by this call after the function execution is completed. will be recycled by the system.

When the function trap is defined, if the function defined inside is saved (for example: assigned to a global variable). Then the scope in which it is located (the scope created when calling the external function) must also be saved together (that is to say, when the execution of the external function ends, the scope created during this call will not be recycled by the system, and it will have to wait until the saved When the function is recycled by the system, it is recycled by the system together).
Scope Saved All local variables in this scope are of course also saved.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template