JavaScript language built-in objects

Source: Internet
Author: User
Tags local time rounds square root

String (String object)
REGEXP (Regular Expression object)
Number (numeric object)
Math (Math object)
function (Functions object)
Error (Exception object)
Date (Day/Time object)
Boolean (Boolean object)
Array (Arrays object)
Arguments (function Parameter object)
Object (Objects Super Class)



1, String
1.1. String.Concat () connection string
Grammar
String.Concat (value, ...)
Note that using the "+" operator to concatenate strings is usually easier.

1.2. String.IndexOf () Retrieving strings
Grammar
String.IndexOf (Substring,start) The second parameter is optional (if default, starts from the first)
The substring to retrieve in a string of strings.
If a substring exists after the start position in string, the position of the first substring that appears is returned. If no substring is found substring returns-1.

1.3, String.LastIndexOf (substring, start) retrieves a string from the back forward

1.4. String.Length (length attribute)

1.5. String.slice (start, end) extracts a substring
Grammar
Start
The starting subscript for the fragment to extract. If it is a negative number, the parameter declares the position from the end of the string. Other words
-1 refers to the last character in the string, 2 refers to the second-lowest character, and so on.

End
The subscript immediately following the end of the fragment to be extracted. If this parameter is not specified, the substring to be extracted includes the string from start to the end of the original string
。 If the parameter is a negative number, it declares the position from the end of the string.

1.6, string.substring (from, to) returns a substring of a string
From
An integer that declares the position of the first character of the substring to be extracted in the string.
To
An optional integer that is 1 more than the last character of the substring to be extracted in the string. If this argument is omitted, the substring returned is until the end of the string.

1.7, String.tolowercase () Convert string to lowercase


1.8. String.touppercase () Converts a string to uppercase


2, REGEXP (regular Expression object)

2.1, Regexp.test (string) detects whether a string matches a pattern
Returns True if the string contains text that matches regexp, otherwise false.
The exception is thrown when the object calling the method is not regexp.

2.2. Regexp.tostring () converts a regular expression to a string
The exception is thrown when the object calling the method is not regexp.


3. Number (Numeric object)

3.1. Number.MAX_VALUE is the largest number that can be represented in JavaScript

3.2. Number.min_value is the smallest number that can be represented in JavaScript (close to 0, but not negative).

3.3. Number.NaN is a special value that shows that some arithmetic operations (such as the square root of a negative number) are not numbers.

3.4, number.tofixed () using fixed-point counting method to format numbers (such as retaining two decimal places)
Grammar
Number.tofixed (digits)
The number of digits after the decimal point is the value between 0~20, including 0 and 20, and some implementations can support a larger range of values. If this argument is omitted, 0 proxies will be used.


4. Math (Math object)

4.1, Math.Abs () Calculate the absolute value

4.2, Math.ceil (x) rounds a number
Greater than or equal to X, and the nearest integer to it.
Math.ceil () performs an up-rounding calculation, which returns an integer that is greater than or equal to the function parameter and closest to it.

4.3, Math.Round (x) The nearest number to X.
Math.Round () rounds or rounds its parameters to the nearest integer.

4.4, Math.floor (x) rounds to a number
is less than or equal to X and is the nearest integer to it.
Math.floor () performs a down-rounding calculation, which returns an integer that is less than or equal to the function parameter and closest to it.

4.5, Math.random () returns a pseudo-random number between 0.0 and 1.0.

4.6, Math.pow (x, y) compute XY
The Y power of X, XY.

4.7, Math.PI Math.PI represents a constant or PI, that is, the circumference of the circle and its diameter ratio, the value is approximately 3.14159265358979.


5. Functions (Function Object)
5.1, Function.prototype
Grammar
Function.prototype
The prototype property is used when a function is a constructor. It refers to an object that is a prototype of the entire object class.
Any object created by this constructor inherits all properties of the object referenced by the property prototype.


6. Error (Wrong object)
6.1. Error.message can read error message


6.2. Rangeerror thrown when the number is outside the legal range

6.3. Referenceerror is thrown when reading a variable that does not exist



7. Date/Time Object

7.1, date.getdate () specifies the day of the month that the Date object dace refers to, using local time. The return value is an integer between 1~31.

7.2, Date.getday () specifies the day of the one week that the Date object refers to date, using local time. The return value is an integer between 0 (Sunday) and 6 (Saturday).


7.3, Date.getfullyear () returns the year field of the Date object


7.4, Date.getmonth () returns the month field of the Date object

7.5, Date.gethours () returns the hour field of the Date object


7.6, Date.getminutes () returns the minute field of a Date object

7.7, Date.getseconds () returns the second field of the Date object

7.7, Date.getmilliseconds () returns the millisecond field of the Date object


8. Boolean (Boolean object)

8.1. Boolean.tostring () converts a Boolean value to a string
Returns the string "true" or "false" based on the original Boolean value or the value stored by the Boolean object B.

8.2, Boolean.valueof () Boolean value of the Boolean object


9. Array (Arrays object)

9.1, the size of the Array.Length array

9.2, Array.push () Add elements to the array

9.3, Array.pop () Delete and return the last element of the array

9.4, Array.Sort () sorting the array elements



10. Arguments (function Parameter object)

10.1arguments[] array of function arguments



11. Object (Super Class)

11.1. Constructor properties for Object.constructor objects
The constructor property of the object references the constructor of the object
For example, if you create an array with the array () constructor, then a.constructor refers to array:
A = new Array (all in all); Create an Object
A.constructor = = Array//evaluates to True


11.2, Object.hasownproperty () check whether the property is inherited

JavaScript language built-in objects

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.