This article is not a zero-based teaching. If you have no javascript basics, turn left first. I learned java before, so this article mainly compares java to learn javascript. Many basic content in JavaScript is basically the same as that in Java, so you do not need to repeat it separately, including:
Various Arithmetic Operators, comparison operators, and logical operators;
If else statement and switch statement;
For Loop, while loop, do while loop;
Tags, break, and continue;
Try catch throw statement.
You can view the Reference Links after the document.
The subsequent content is different parts of JavaScript.
In this article, we will talk about several details in the above section.
1. Full equality judgment
The comparison operator of JavaScript has a full equality ===, which is used to determine whether the values and types are equal.
2. for/in Loop
The for/in loop in JavaScript is a bit like the enhanced for loop in Java, but it is used to traverse the attributes of objects.
The Code is as follows:
Var person = {fname: "John", lname: "Doe", age: 25 };
For (x in person)
{
Txt = txt + person [x];
}
Here, x is the property name, and person [x] is the value of this property.
3. With statement
With the With statement, you do not need to specify the reference object again when accessing the object attributes and methods. In the With statement block, any properties and methods that JavaScript does not recognize are related to the objects specified by the statement block.
Function: Creates a default object for a program.
Format: ( <对象> ){ <语句组> }
That is:
The Code is as follows:
With Object {
Statements
}
For example, when using the write () or writeln () method related to the Document object, the following format is often used:
The Code is as follows:
Document. writeln ("Hello! ");
If you need to display a large amount of data, the same document will be used multiple times. writeln () statement. In this case, all the statements With Document objects as reference objects can be placed in the With statement block as the program below to reduce the number of statements.
The Code is as follows:
WithTest.html