Codefordream About JS Intermediate training

Source: Internet
Author: User

The mid-level training then began with a busy start.

The first is about variables, the role of variables is to give a data value label name. Note: The naming conventions for variable names, function names, and parameter names in javascript: At least one of the letters, underscores, dollar signs, numbers, but not the numbers. The definition of a variable, such as: var num = 5. As for the reference to the variable, I think this sentence has already been said to be very image--the data originally does not have the name, the reason uses the variable, is to use a name to call such a kind of data that does not have the name. The so-called "reference" can be thought of as the variable name to take out the data value it represents. It's like in a lot of boxes to find the contents of the box through the name of the box. The variable name, like num above, is a box that contains 5 such a thing, of course, object to objects, where the face is like a lot of boxes, the box and put values.

Then the code is running, JS code is from top to bottom, from left to right in turn, but in one case, that is, the definition of the statement. When the code is running, the definition statement in Javacript is executed before all code, but it should be written before the calling variable for convenience. It is worth mentioning that the pre-execution is only the definition of the statement, but about the assignment statement is not advanced, for example:

Console.log (num);

var num = 5;

Console.log (num);

Running this code output is:

Undefined

5

Then it is about the nesting of functions, functions to nesting is inside the function can also declare and call functions, a bit recursive meaning, but recursive is to call themselves, in fact, recursion is very powerful, as Nickeraus Wilter said, recursion is powerful in that it allows users to describe the infinite object with limited statements. Thus, in computer science, recursion can be used to describe infinite-step operations, although the procedure for describing operations is limited. A very simple factorial example:

The nesting of functions is to declare or invoke another function inside the function.

The last thing to talk about is the scope. Scope refers to the valid range of names (variable names and function names). There are two scopes in Javascrpit: 1. Global scope 2. The local scope global scope refers to the scope outside of all functions (that is, the outermost code). A variable or function declared outside of all functions is a global scope, and a variable in the global scope is a global variable. A function in the global scope is a global function. A local scope is any variable or function that is declared inside a function that is valid only within the function, either as a local variable or as a function. Note: When a variable name is both a local variable and a global variable, the local variable is given precedence. That is, the local variable takes precedence over its scope than the variable with the same name in the outer scope. As I understand it, it takes precedence to assign a value closer to the variable, which is the nearest principle.

JS Intermediate training is probably the case.

Codefordream About JS Intermediate training

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.