Mark's related knowledge points:
First, what is JS's built-in object, what does it include? (The following content is transferred from the integration of resources on the Internet)
(W3shool JS manual address: http://www.jb51.net/w3school/js/js_reference.htm)
As a programming language, JavaScript provides some built-in objects and functions. Built-in objects provide several of the most commonly used features of programming. JavaScript built-in objects have several of the following.
String object: Handling all string operations
Math object: Handling all mathematical operations
Date object: Handling the storage, transformation, and expression of dates and times
Array object: Provides an array of models, storing a large number of ordered data
Event object: Provides various processing information for JavaScript events
Built-in objects have their own methods and properties, which are accessed in the following ways:
Object name. Property name
Object name. Method Name (parameter list)
1. Time Object
A time object is a built-in object of JavaScript that must be declared before use.
Basic syntax
var curr=new Data ();
Note the use of the keyword new here, the first letter of Data () must be capitalized.
Grammar explanation
Use new to declare a new object entity. The syntax for using the new operator is as follows:
Instance object name =new object Name (argument list)
The Date object provides the following 3 types of methods:
Get the current time and date from the system
Set the current date and time
Complete the conversion between time, date, and string
The following table describes the most commonly used methods of obtaining a system's time and date
Methods for processing time and dates in a Date object
Type of method |
Method name |
Description of work Energy |
get time or date |
getDate |
get the current date |
get time or date |
getday |
get the current day |
get time or date |
getHours |
get the current hour |
get time or date |
getminutes |
get the current minute |
get time or date |
getmonth |
get the current month |
get time or date |
getseconds |
get the current seconds |
get time or date |
getTime |
get current time (in milliseconds) |
get time or date |
gettimezoneoffset |
get the current time zone offset information |
get time or date |
getyear |
get the current year
|
Practice NOTES:
<!--note the difference between getdate and getday, GETDATE returns a date (1-31), and Getday returns the day of the week ()-->
<!--also note that creating an array remembers to use the keyword new, such as: Var myarray=new array ()-->
<!--also learned two ways to assign values to arrays:
1, the first method can create any number of values, similar to the creation of any number of variables like:
Such as:
var mytechnic=new Array ()
mytechnic[0]= "HTML"
mytechnic[1]= "CSS"
mytechnic[2]= "JS"
You can also use an "integer argument" to control the capacity of an array.
2, the second method:
var mycars=new Array ("Saab", "Volvo", "BMW")
If you want to modify the values in the array, assign a new value directly: mytechnic[2] = "jquery"
-->
2. Mathematical objects (more abstract)
The built-in math object can be used to handle a variety of mathematical operations. Some commonly used mathematical constants, such as Pi pi=3.1415926, are defined. Various operations are defined as built-in methods of the Math object, and can take advantage of directly invoked methods.
Basic syntax
Math. Mathematical functions (parameters)
Or
With (Math)
{
Mathematical functions
}
Grammar explanation
The WITH statement provides a simple and clear way to express the relationship between its properties and methods. Simply put, in the scope of the with and the statement, the object's properties and methods are defined as the default object, and the default object is given at the beginning of the WITH statement. The syntax for using the WITH statement is as follows:
With (object name)
{
Statement block ...
}
3. String Object
Strings are typically processed using functions provided by String objects. String processing of strings mainly provides the following methods.
CharAt (IDX): Returns the character at the specified position
IndexOf (CHR): Returns the position of the specified substring, from left to right. Could not find return-1.
LastIndexOf (CHR): Returns the position of the specified substring, from right to left. Could not find return-1.
toLowerCase (): Converts all characters in a string to lowercase.
toUpperCase (): Converts all characters in a string to uppercase.
4. Array objects (tonight special emphasis on this one-array Object!) )
Basically all programming languages provide array objects, and arrays organize the same kind of data together, accessible and efficient. Like the Java and C languages. JavaScript and C, the subscript of an array is a bundle of zeros. Once an array is created, you can access the individual elements of the array with the [] symbol.
The following is a summary of some of the manual types (for JS built-in objects):
1.Date
Properties (1):
The function reference of the object established by constructor
Prototype attributes and methods that can be added to an object
Method (43):
Getday () returns the day ordinal of a week (0-6)
GetYear () returns the year. 2000 ago was 2 digits, 2000 (inclusive) after 4-bit
getFullYear () returns the full 4-digit year number
GetMonth () returns the number of months (0-11)
GetDate () return date (1-31)
GetHours () Back hours (0-23)
Getminutes () return minutes (0-59)
Getseconds () returns the number of seconds (0-59)
Getmilliseconds () returns milliseconds (0-999)
getUTCDay () According to international time to get now is the day of the Week (0-6)
getUTCFullYear () According to international time to get the complete year
getUTCMonth () According to international time to get the month (0-11)
getUTCDate () According to international time to get the day (1-31)
getUTCHours () According to international time to get the hour (0-23)
getUTCMinutes () Returns minutes according to international time (0-59)
getUTCSeconds () Returns seconds based on international time (0-59)
getUTCMilliseconds () returns milliseconds based on international time (0-999)
GetTime () returns the number of milliseconds to spend from January 1, 1970 0:0:0 to now
getTimezoneOffset () returns the time zone deviation value, that is, the number of minutes between Greenwich Mean Time (GMT) and the time zone setting of the computer where the script is run.
Parse (datestring) returns the number of milliseconds since January 1, 1970 00:00:00 in the date string
Setyear (Yearint) set year. 2-digit or 4-digit number
setFullYear (Yearint) set year. 4 digits
Setmonth (Monthint) Set month (0-11)
Setdate (Dateint) Set Day (1-31)
Sethours (Hourint) Set number of hours (0-23)
Setminutes (MININT) set number of minutes (0-59)
Setseconds (Secint) Set number of seconds (0-59)
Setmilliseconds (Milliint) set milliseconds (0-999)
setUTCFullYear (yearint) sets the year according to international time
setUTCMonth (Monthint) set the month according to International Time (0-11)
setUTCDate (Dateint) set the day according to International Time (1-31)
setUTCHours (hourint) Set hours according to international time
setUTCMinutes (MININT) Set minutes according to international time
setUTCSeconds (Secint) Set seconds according to international time
setUTCMilliseconds (Milliint) sets milliseconds based on international time
SetTime (Timeint) sets the time from January 1, 1970. Number of milliseconds
toGMTString () Converts the Date object's dates (a numeric value) to a GMT time string based on GMT, such as: weds,15 June l997 14:02:02 GMT
toUTCString () Converts the date of one Date object to a string based on the universal Time
toLocaleString () Turns the Date object's dates (a numeric value) into a string, using a specific date format that is configured on the computer that is used
Tosource () Displays the source code of the object
ToString () Converts a Date object to a string
UTC (yyyy, MM, DD, hh, MM, SS, msec) returns the gap from Greenwich Mean time to a specified time, in milliseconds
ValueOf () returns the original value of the Date object
2.Math
Property:
The function reference of the object established by constructor
Prototype attributes and methods that can be added to an object
E Euler constant, base of natural logarithm (approximately equal to 2.718)
The natural logarithm of the LN2 2 (approximately equal to 0.693)
The natural logarithm of the LN10 10 (approximately equal to 2.302)
LOG2E the logarithm of the 2-base E. (approximately equal to 1.442)
LOG10E the logarithm of the 10-base E (about 0.434)
Value of Pi∏ (approximately equal to 3.14159)
Sqrt1_2 1/2 (0.5) square root (i.e. l divided by 2 square root, approximately equal to o.707)
SQRT2 2 square root (approximately equal to 1.414)
Method:
ABS (x) returns the absolute value of a number
ACOs (x) returns the inverse cosine of a number
ASIN (x) returns the inverse chord value of a number
Atan (x) returns the tangent value at-PI/2 and PI/2
ATAN2 (y,x) return (x,y) at the angle between-pi and PI
Ceil (x) returns the largest integer after X rounding
COS (x) returns the cosine of a number
EXP (x) returns E^X value
Floor (x) returns the smallest integer after x rounding
Log (x) returns the natural logarithm of the base E
Max (X,y) returns the larger number between x and Y
MIN (x,y) returns the smaller number between x and Y
POW (x,y) returns the value of Y^x
Random () returns a random function that is between 0 and 1
Round (x) rounded after rounding
Sin (x) returns the sine value of a number
SQRT (x) returns the square root of a number
Tan (x) returns the tangent of an angle
Tosource () Displays the source code of the object
ValueOf () returns the original value of the mathematical object
3.Number
Property:
Max_value the largest possible VALUE a number in JavaScript can have 1.7976931348623157E+308
Min_value the smallest possible VALUE a number in JavaScript can have 5E-324
NaN Equal to a value, not a number.
Negative_infinity A value is less than Min_value.
Posotive_infinity A value is greater than max_value.
Prototype A static property of the Number object
Method:
ToString Returns A string representing the specified object
ValueOf () returns the original value of the mathematical object
4.Boolean
Property:
The function reference of the object established by constructor
Prototype attributes and methods that can be added to an object
Method:
Tosource () Displays the source code of the object
ToString () converts a Boolean value to a string and returns the result
ValueOf () returns the original value of the Boolean object
5.String
Property:
The function reference of the object established by constructor
Prototype attributes and methods that can be added to an object
Length returns character lengths of strings
Method (20):
Anchor ("name") is used to convert the string into an HTML anchor tag (<a name=>).
Big () turns the text in the string into a large font (<BIG>)
Blink () changes the text in the string to a blinking font (<BLINK>)
Bold () turns the text in the string into a black font (<B>)
Fixed () turns the text in the string into a stationary spacing font, or telegraph form (<TT>)
FontColor (color) sets the colors of the text in the string (<font color=>)
FontSize (size) To change the text in a string to a specified size (<FONTSIZE=>)
Italics () The text in the string into a italic font (<I>)
Link (URL) is used to convert the string into-html link tags (<a href=>)
Small () turn text in a string into a small font (<SMALL>)
Strike () The text in the string into a crossed font (<STRIKE>)
Sub () To turn text in a string into subscript (subscript) font (sub>)
SUP () turns the text in the string into superscript (superscript) font (<SUP>)
CharAt (index) returns the character at the specified index
charCodeAt (index) returns an integer that represents the Unicode encoding of the character at the specified position in the string object
Concat (string2) connection two or more strings
fromCharCode (NUM1, num2, ..., numn) gets the specified Unicode value and returns a string
IndexOf (searchstring, StartIndex) returns the position of the first occurrence of the specified string in the string
Lastlndexof (searchstring, StartIndex) returns the position of the last occurrence of the specified string in the string
Match (Regex) finds the specified value in a string
Replace (regex, newstring) replaces certain characters in a string with other characters
Search (regex) to find a string for an execution value
Slice (StartIndex, endindex) extracts some characters and returns the remainder in a new string
Split (delimiter) assigns a string to an array
substr (startIndex, length) from StartIndex, take length characters
SUBSTRING (StartIndex, endindex) the characters between StartIndex and Endindex, excluding Endindex
toLowerCase () turns text in a string to lowercase
toUpperCase () to capitalize text in a string
Tosource () Displays the source code of the object
ValueOf () returns the original value of the string object
6.Array
Property:
The function reference of the object established by constructor
Prototype attributes and methods that can be added to an object
The index for an array created by a regular expression match, the zero-based index of the match in the string.
Input for an array created by a regular expression match, reflects the original string against which the regular Expressio N was matched.
Length gets the number of elements in the array, that is, the maximum subscript plus 1
Method (13):
Concat (Array1,arrayn) joins two or more than two array values and returns the result after merging
Join (string) merges the elements of an array into a string, and string is a separator. If omitted, the argument is merged directly, no longer separated
Pop () moves the last element in the divisor group and returns the element
Push (value) adds one or more elements to the end of the array and returns a new array length value
Reverse () Reverses the order of elements in the array, reversing
Shift () to move the first element in the divisor group and return the element
Slice (start, deletecount, [item1[, item2[,... [, Itemn]]] Returns one or more elements from an array and, if necessary, inserts a new element at the position of the removed element, returning the removed element
The sort (compare Function), in the case of unspecified sorting numbers, is arranged alphabetically by element, if not a string type, and then sorted to a string, returning the sorted array
Splice () deletes an array and adds a new element
Tosource () Displays the source code of the object
ToString () returns all elements of an array to a string, separated by commas
Unshift (value) adds one or more elements to the beginning of the array and returns the new length
ValueOf () returns the original value of an array object
7.RegExp
Property:
$ parenthesized substring matches, if any.
$_ to the input.
$* Multiline.
$& lastmatch.
$+ Lastparen.
$ ' leftcontext.
$ ' rightcontext.
Global Whether or not to test the regular expression against all possible matches into a string, or only against the.
IgnoreCase Whether or not to ignore case while attempting a match in a string.
Input the string against which a regular expression is matched.
Lastindex the index at which to start the next match.
Lastmatch the last matched characters.
Lastparen the last parenthesized substring match, if any.
Leftcontext the substring preceding the most recent match.
Multiline Whether or not to search in strings across multiple lines.
Rightcontext the substring following the most recent match.
SOURCE the text of the pattern.
Method:
Compile compiles a regular expression object.
EXEC executes a search for a match in its string parameter.
Test Tests for a match on its string parameter
8.Function
Property:
Arguments an array corresponding to the arguments passed to a function.
Arity indicates the number of arguments expected by the function.
The caller specifies which function called the current function.
Prototype allows the addition of properties to a Function object.
Method:
ToString Returns A string representing the specified object.
9.Object
Property:
constructor specifies the function that is creates an object ' s prototype.
Prototype allows the addition of properties to all objects.
Method:
Eval evaluates a string of JavaScript code in the context of the specified object.
ToString Returns A string representing the specified object.
Unwatch removes a watchpoint from a property source the object.
valueof Returns The primitive value of the specified object.
Watch Adds a watchpoint to a property source the object.
10. Global
Property:
Infinity specifies a value of positive and negative infinity
NaN specifies a "non-numeric" value
Undefined specifies a variable that is not assigned a value
Method:
decodeURI () to decode the encrypted URI
decodeURIComponent () decoding for the encrypted URI component
encodeURI () encrypts a string as a URI
encodeURIComponent () encrypts a string as a URI component
Escape (String) encrypt a string
Unescape () decodes a string using escape ()
Eval (string) to judge a string and execute it as script code
Isfinite (number) detects whether a value is a finite digit, returns TRUE or False
isNaN (String) detects whether a value is not a finite number
Number () Converts the value of an object to a numeric
parsefloat (String) resolves a string to a floating-point number
parseint (String) resolves a string to an integer, not rounding, but cutting the tail
String (object) converts an object value to a string
Number (object)
11. The Event
Property:
A. Window events, only valid in body and FRAMESET elements
When the onload page or picture finishes loading
OnUnload when the user leaves the page
B. Form element events, valid in form elements
OnChange when the contents of the box change
When onsubmit click the Submit button
OnReset When you click the mouse button again
When Onselect text is selected
When the onblur element loses focus
Onfocus when the element gets the focus
C. keyboard events that are not valid in Base,bdo,br,frame,frameset,head,html,iframe,meta,param,script,style,title elements
OnKeyDown Press the keyboard key
onkeypress Press or hold down the keyboard key
onkeyup When you release the keyboard keys
D. Not in the Base,bdo,br,frame,frameset,head,html,iframe,meta,param,script,style,title element.
OnClick mouse clicks on an object when
OnDblClick mouse to double-click an object
When the onmousedown mouse is pressed
OnMouseMove when the mouse is moved
onmouseout when the mouse leaves the element
onmouseover when the mouse passes over elements
When onmouseup releases the mouse button
E. Other
onresize when a window or frame is redefined as a dimension
When the onabort picture download was interrupted
OnError When an error occurs when loading a document or picture
Custom objects: Two methods of objects with initialization objects and defining constructors
A: Initializing objects
For example: Object ={Property 1: Value 1; Property 2: Value 2; Attribute N: Value n} Note: Separate each property/value pair with a semicolon;
B: Define the object of the constructor
For example:
function functions Name (property 1, Property 2,...... Attribute N) {
this. Property 1 = property value 1;
this. Property 2 = property value 2;
This. Property N= property value N;
This. Method Name 1 = function Name 1;
This. Method Name 2 = function Name 2;