The concept of javascript--objects--built-in objects

Source: Internet
Author: User

All objects that include built-in objects are child objects of object objects.

1. Array (): Build the built-in constructor function of the array

Example: There are two ways to create an array:

2. Boolean: Is an object that is not the same as a Boolean value of the base data type

Example: Create a Boolean object.

in the example above, a is an object and not a Boolean value. Its Boolean value can be obtained by valueof (). Typically, a Boolean object is not used to create an object, but instead uses that object to cast the data type.

When casting, the following will be converted to false: empty string '; null;undefined; number 0; Nan;false;

Cases:

That is: The Boolean has the following two functions

    • General function: Converts any value to a Boolean value;
    • Constructor function: Creates an object.

3. Number

The same as the above, has two functions.

    • General functions: Convert data to numbers, similar to parseint (), parsefloat ();
    • Constructor function: Used to create a function.

Cases:

Common Properties:

    • The maximum value of the Number.MAX_VALUE:Number;
    • The minimum value of the Number.MIN_VALUE:Number;
    • Number.POSITIVE_INFINITY: denotes positive infinity INFINITY;
    • Number.negative_infinity: Indicates negative infinity large-infinity;
    • Number.NaN: Indicates not a number.

Common methods:

    • toFixed (int): Returns a string in the form of a number, the parameter is a decimal place, rounded;
    • toexponential (int): Similar to the above, but in exponential form.
    • toprecision (int): The result may be any of the two methods above.

4. String object: Differs from string of basic data type

Example 1:string the difference between an object and a string

Example 2:

A string object is essentially an array of characters that contains the Index property and the length property of each character. The string itself is not an object, there are no properties and methods, but you can use the properties of the string object because JavaScript creates a corresponding string object and then calls the properties and methods, and then destroys the string object after the method is called. Therefore, the string can also use the indexed property and the length property.

String () is the same as the previous one and has two functions:

    • Used as a constructor function to create a string object;
    • Used as a general function to cast a parameter to a string;

Example 3: Casting data into a string

Common methods for string objects:

(1) toUpperCase (), toLowerCase (): Convert case;

(2) CharAt (): Returns the character at the specified position, without returning an empty string;

(3) IndexOf (String1,start): From start (including start) The forward search string1, return to its position, no return-1;

(4) LastIndexOf (String1,start): Reverse search string1 from start (including start), return to its position, no return-1;

(5) Slice (Start,[end]): Gets the string from start (containing start) to end, if start, end is a negative number, indicates that the from position is from the back, and if not, returns an empty string '; if there is no end argument, it is the last.

(6) substring (start,end): Similar to Slice (start,end), but does not accept negative numbers, and when Start<end, will automatically replace the position of two parameters, in the execution.

(7) Split (Separator[,int]): The string is divided according to the parameter separator to the maximum number of int, if an empty string ("") is used as separator, then each character in the Stringobject is divided. Separator can be either a string or a regular expression.

    • String: The array is created by splitting the string stringobject into substrings at the boundary specified by separator. The string in the returned array does not include the separator itself.
    • Regular Expressions: The returned array includes strings that match these sub-expressions (but does not include text that matches the entire regular expression).

(8) concat (String): Connection string, Example:

(9) Search (REGEXP): Returns the position of the substring of the first matching regular expression, returns 1 if no matched substring is found, ignores the LastIndex property of RegExp, and always retrieves from the beginning of the string

Replace (regexp/substr,replacement): Used to replace characters with some characters in a string, or to replace a substring that matches a regular expression.

(one) match (STRING|REGEXP): the match() method retrieves the specified value within a string, or finds a match for a regular expression or string. The method is similar to IndexOf () and lastIndexOf (), but it returns the specified value instead of the position of the string.

(anchor): used to create an HTML anchor (anchorname)

The concept of javascript--objects--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.