Chapter 5, JavaScript built-in object
1. JavaScript Type of Built-in Object
The implicit object such as Var str = "javascript" does not support the Prototype and Expando properties
Objects created by New instructions
2.JavaScript built-in object
Boolean object objboolean = new boolean () Boolean value for false, 0, null, nan or empty string is false, otherwise true
Function object 1, function mod (x, y) {
Return (X% Y);
}
Second, VAR MOD = New Function ("X", "Y", "Return (X% Y)");
Global objects do not need to be established using the New instruction. This object is automatically established after the Script engine is initialized. Global object has two properties
Infinity gets the initial value of Number.positive_infinity
NAN gets the initial value of Number.nan
The properties of the Global object do not have to specify the Global object, and use the attribute name directly.
Number objects typically, we use the Number object to use the toString () method. Attributes:
MAX_VALUE Returns the maximum value of the JavaScript value, about 1.79E 308
Min_Value Returns the value of JavaScript closest to 0, about 5.00e-324
Nan This is a special value, indicating that the expression or variable value is not a value.
Negative_infinity Returns a bigger negative value than -Number.max_Value
Positive_infinity Returns a bigger positive value than Number.max_Value
Object objects can establish objects supported by JavaScript
Regexp Objects JavaScript Standard Language (Regular Expression) object.
String Object String object provides a series of formatted methods:
Anchor (), BIG (), Blink (), Bold (), Fixed (), FontColor (Color), Fontsize (size),
ITALICS (), LINK (URL), Small (), Strike (), SUB (), SUP ()
String length, uppercase and search:
Length gets the length of the string, TOLOWERCASE (), TouPercase ()
Charat (index) get the character index value of the parameter index position starts from 0,
Charcodeat (INDEX) gets the parameter index location Unicode unified encoding
IndexOf (String, INDEX) Returns the index location of the string for the first time. Did not return -1. INDEX is the location where you start searching.
LastIndexof (String)
Match (string) with indexof, returns a found string. No NULL returns.
Search (String) with indexof
String processing:
Replace (String1, String2) finds String1 replacement to string2
Split (string) Split Returns Array array
Substr (INDEX, Length) starts Length character from Index
Substring (Index1, Index2) Removes the string between Index1 to Index2
Concat (SRING) Adds String Behind the String Object
Array object declaration var username = new array (5);
Array object properties and methods
Lengthjoin () Displays the elements of the array using the string mode display by ','
Reverse () reverse number group
Sort () sort
Concat (array)
Array object of multidimensional array JavaScript does not directly support multi-dimensional arrays but Array object elements can be another array object
// Establish a two-dimensional array
VAR users = new array (5);
FOR (var i = 0; i <5; i )
Users [i] = new array (2);
Users [0] [0] = "joe";
Users [0] [1] = "1234";
Users [1] [0] = "jane";
Users [1] [1] = "5678";
Users [2] [0] = "tony";
Users [2] [1] = "9012";
Users [3] [0] = "Tom";
Users [3] [1] = "1234";
Users [4] [0] = "merry";
Users [4] [1] = "5678";
// Use a loop display array value
For (var j = 0; j For (i = 0; i Document.write (users [j] ",") Document.write (" } script> Date object acquisition date and time GetDate () Back Date 1-31 Getday () returns to the week 0-6 Sunday to Saturday GetMonth () returns to the month 0-11 from January to December GetFullyear () Returns the full year such as: 2004 GetYear () returns two after the year GetHours () Returns Hours 0-23 getminutes () Returns minutes 0-59 Getseconds () Return to the second number 0-59 getMilliseConds () Returns the number of seconds of one thousand seconds 0-999 GetTime () returns the number of seconds starting from 1/1/1970, in one thousandth of one second Set date and time No setday (), other one by one The Date object provides a set of corresponding methods, for example: setDate () has corresponding setutcdate (), getHours () has a corresponding getutsuRS () Date and time conversion GetTimezoneoffset (), Togmtstring (), Tolocalstring (), Parse (DATE), UTC (Date) JavaScript hour clock. Timer method for Window object setTimeout () and cleartimeout ()
");
VAR Timer = NULL;
// Display Digital Picture
Function DisplayClock (NUM) {var Dig = PARSEINT (NUM / 10);
VAR TIMETAG = ""
DIG = NUM% 10;
TimetaG = ""
Return Timeta;
}
// Stop
Function StopClock () {
Cleartimeout (Timer);
}
// start the timer
Function startClock () {
VAR TIME = New Date ();
// get time
Var Hours = DisplayClock (Time.GetHours ()) ":";
VAR Minutes = DisplayClock (Time.getminutes ()) ":"
VAR Seconds = DisplayClock (Time.GetSeconds ());
// display time
Show.innerhtml = Hours Minutes Seconds;
Timer = setTimeout ("StartClock ()", 1000);
}
script>
hEAD>