JavaScript objects are instantiated and can only be used but cannot create new subclasses inherited from these objects.
The window object is the Parent of all objects.
The main attributes of the window object are: Name, Length, Parent, Self, Top, Status, Default Status, Opener, Closed.
The main methods of the window object are: Item, alert, blur, close, confirm, open, focus, showModalDialog.
Commonly used attributes of Document objects: alinkcolor, Anchors, bgcolor, cookie, domain, embeds,
fgcolor, layers, linkcolor, location, title, url, vlinkcolor
Use of Anchors attributes:
function goNextAnchor(where )
{
window.location.hash = where ;
}
Creation of array object:
function students(name,age)
{
this.name = name ;
this.age = age ;
}
stu1 = new students("thtwin",22) ;
stu = new Array(5 ) ;
stu[0] = "thtwin" ;
stu[1] = "thtwinj2ee" ;
.....
stu.length //The length of the array
Related methods of the Math object are used:
Math.abs(arg); //Find the absolute value of the number set by the user
Math.max(arg1,arg2); //Return the two numbers Larger value
Math.round(arg1); //Round the floating point number to the nearest integer>0.5, otherwise the decimal places will be lost
Math.floor(arg1); //What you are looking for is Less than or equal to the value of the variable
Math.ceil(arg1); //Greater than or equal to the value of the variable
Math.random(); //Generate a random number between 0 and 1
Date object in JavaScript:
This object has no attributes, but the time can be set through some methods.
It is forbidden to use time before January 1, 1970.
thisDay = new Date();
thisDay = new Date(month day,year hours:minutes:seconds);
thisDay.getYear();
thisDay.getMonth();
thisDay.getDate();//Return a month The date value in . This method directly returns a date value between 1 and 31
thisDay.getDay() ;
thisDay.getTime() ;//Returns an integer value representing the current date. (192687456985)
thisDay.getHours() ;
thisDay.getMinutes() ;
thisDay.getSecondes() ;
thisDay.toLocaleString() ;//Return the string value of the time
Usage of With statement
With(Object)
{
statements;
}
Note: There is no need to repeatedly specify the reference object when accessing object properties and methods. In the With statement In the block, all properties and methods not recognized by JavaScript
are related to the object specified by the statement block. For example:
When using the write() or writeln() method related to the Document object, the following form is often used :
document.writeln("Hell!") ;
If you need to display a large amount of data, you will use the same document.writeln() ; statement multiple times. In this case, you can
like the following program In that way, put all the object statements that refer to the Document object into the With statement block, thereby
achieving the purpose of reducing the number of statements. The following is an example of using the With statement: