JavaScript built-in object properties and methods Collection _ Basics

Source: Internet
Author: User
Tags array length italic font natural logarithm numeric value square root value of pi
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_r match, the zero-based index of the match in the string.
Input for an array created by a regular expression_r match, reflects the original string against which the regular express Ion_r 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_r against all possible matches in 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_r 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_r 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:
Uates 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 ()
(string) to judge a string and execute it in the form of scripting 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;
}

Note: The method name and function name can have the same name, but before the method calls the function, the function must already be defined, or there will be an error.

Just as you create a new instance for a custom function, you use the newly statement.
Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.