Some knowledge points that should be paid attention to when learning JavaScript. (From & lt; JavaScript Advanced Programming & gt;) JavaScript objects are instantiated, you can only use it but cannot create new subclasses that inherit from these objects.
The window object is the Parent of all objects.
Window objects have the following attributes: Name, Length, Parent, Self, Top, Status, Default Status, Opener, and Closed.
The main methods of window objects are: Item, alert, blur, close, confirm, open, focus, showModalDialog.
Common attributes of a Document Object: alinkcolor, Anchors, bgcolor, cookie, domain, embeds,
Fgcolor, layers, linkcolor, location, title, url, vlinkcolor
Anchors attribute usage:
Function goNextAnchor (where)
{
Window. location. hash = where;
}
Create an 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 // array length
Usage of Math objects:
Math. abs (arg); // calculates the absolute value of the number of user settings.
Math. max (arg1, arg2); // return a greater value of the two numbers.
Math. round (arg1); // rounds the floating point number to an integer greater than 0.5. Otherwise, the decimal point is dropped.
Math. floor (arg1); // calculates the value smaller than or equal to the value of the variable.
Math. ceil (arg1); // value greater than or equal to the value of the Variable
Math. random (); // generates a random number between 0 and 1.
Date objects in JavaScript:
This object has no attributes, but you can set the time in some ways.
The time before January 1, January 1, 1970 is forbidden.
ThisDay = new Date ();
ThisDay = new Date (month day, year hours: minutes: seconds );
ThisDay. getYear ();
ThisDay. getMonth ();
ThisDay. getDate (); // returns the date value of a month. This method returns a date value between 31 and 1.
ThisDay. getDay ();
ThisDay. getTime (); // returns an integer representing the current date. (192687456985)
ThisDay. getHours ();
ThisDay. getMinutes ();
ThisDay. getSecondes ();
ThisDay. toLocaleString (); // returns the string value of the time.
Use of With statements
With (Object)
{
Statements;
}
Note: When accessing object attributes and methods, you do not need to specify the reference object repeatedly. In the With statement block, all JavaScript
The unrecognized attributes and methods are related to the objects specified by the statement block. For example:
When using the write () or writeln () method related to the Document object, the following format is often used:
Document. writeln ("Hell! ");
If you want to display a large amount of data, the same document. writeln (); statement is used multiple times.
As in the following program, put all the statements of the objects referenced by the Document object into the With statement block.
To reduce the number of statements, the following is an example of the With statement:
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