JavaScript string Object

Source: Internet
Author: User

JavaScript string Object

First, the attribute

1.length

Calculates the length of a string (not distinguished between Chinese and English)

2.constructor

The constructor of the object

Get type

1. String object. charAt (num)

Returns the character at the specified position.

2. String object. charCodeAt (num)

Returns the Unicode encoding of the character at the specified position

3. String.fromCharCode ()

Accepts one or more specified Unicode values, and then returns one or more

String. It cannot be used as a method of a String object that you have created.

Find type

1. String object. IndexOf ("")

Returns the position of the first occurrence of a specified string in a String object

2. String object. LastIndexOf ()

Returns the location of the last occurrence of the specified string value

3. String object. Match ()

Retrieves the specified value in a string, the value returned is the specified value

4. String object. replace (target value, replacement value)

Replace some characters in a string with some other characters

Interception type

1. String object. Slice (start,end)

All strings from the specified start position to the end position (not included). If you do not specify an end position,

From the specified start position, the end is taken

The slice parameter can be a negative number, or, in the case of a negative number, the end of the string, starting with 1.

2. String object. substr (Start,length)

Takes a string of the specified length from the specified position. If no length is specified, the start of the specified

The position is taken to the end.

Conversion type

1. String object. Split ()

To split a string into an array

2. String object. toLowerCase ();

Used to convert a string to lowercase.

3. String object. toUpperCase ()

Convert a string to uppercase

JavaScript string Object

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.