1. Objects in JS are indeed more convenient. Similar to classes in C ++, they can contain methods and attributes, greatly simplifyingCodeAnd optimized code management.
The definition of an object is actually very simple, that is, to define a constructor of the object. For example:
Function card (name, address, work, home)
{
This. Name = Name; this. Address = ""; this. Work = "";
} In this way, an object is defined, and its member attributes include name, work, address;
If a function a () {alert (this. name) ;}; then add this in the constructor. func1 = A; therefore, the object card has a member function func1; where this indicates the current object;
When using an object, it is similar to a class. You must declare an instance first. For example, VAR C1 = new card ("D", "C", "F"); therefore, c1.func1 ();
2. How to extend the built-in object is simply using the keyword prototyp;
Eg. String. Prototype. funcnew = func; therefore, the string class adds a function funcnew (assuming that func is the function name );
Using objects makes it easier to maintain data and even integrate with databases. In ASP. net2.0, Ajax framework can be used to make server-side objects directly used by clients;
At the same time, objects can also contain more objects, and objects can be used as array elements;
3. In addition to If else switch for while, the control statements supported by js also support do while, for in, break, and continue;
What is the colon syntax supported at the same time? :; Short circuits of logical expressions are supported.
The comparison operator = is used to compare different types of values. Earlier versions are converted to the same type before comparison. Later versions are considered different directly. However, after testing, it seems that all the changes will be converted before comparison. This is a bit confusing ??? (Give me some advice)
4. The With keyword is used to specify an object. In the subsequent statement block, attributes of an object not specified for each statement are considered as attributes of the object.
EG with (C1) {name = "AA";} // The name is c1.name;
5. the built-in object math is special. Its method is similar to the static method and can be called directly without declaring an instance. Such as math. Cos (60 );