Home > Web Front-end > JS Tutorial > body text

Scope analysis of variables within js functions_javascript skills

WBOY
Release: 2016-05-16 16:21:00
Original
1118 people have browsed it

The example in this article analyzes the scope of variables within the js function. Share it with everyone for your reference. The specific analysis is as follows:

Let’s look at a function example first:

Copy code The code is as follows:







Unlike PHP, if you want to call a variable in a JS function, it first searches it within the function. For example, in the example, a is equal to 6; but c cannot be found in the function body, so it will look up outside the function body. If it finds it, it will be called. If it cannot find it, it will report an error.

I hope this article will be helpful to everyone’s JavaScript programming design.

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