JavaScript built-in object-string

Source: Internet
Author: User
Tags joins

A string is defined in JavaScript by double or single quotation marks.

the string object has only one property: The length property , which gets the lengths of the strings.

Methods for handling the string itself

CharAt (Index)

Returns a character at the specified position of index in the string.

charCodeAt (Index)

Returns the Unicode encoding of the character at index at the specified position in the string ( An integer between 0~65 535 that returns NaN if the index exceeds the string range ).

Concat (STR2)

Joins the string Str2 to a new string after the current string, with the same functionality as the "+" operator.

fromCharCode ()

a static method of a string object that encodes each integer specified in the argument list as a Unicode character , and joins the characters to create a string.

IndexOf (str[, StartIndex])

Finds a substring from left to right in the current string and returns a substring when str first appears in the string, the starting (first letter) position index of the substring, and returns 1 if it is not found .

LastIndexOf (str[, StartIndex])

As with the indexOf (str[, StartIndex]) method, the substring is found in the current string str, but the direction of the lookup is right-to-left.

Localecompare (str)

Compares the current string with the parameter string by default comparison rules provided by the local operating system STR, if the current string is greater than str, returns an integer greater than 0 , or less than 0 if less than str An integer that returns 0 if it is equal .

Match (REGEXP)

Searches for a string using the specified regular expression.

Replace (REGEXP, ReplaceText)

Replaces a string with the specified regular expression.

Search (REGEXP)

Searches for a string using the specified regular expression.

Slice (StartIndex [, EndIndex])

Extracts a substring from the current string and returns the substring determined by the parameters StartIndex and endIndex .

Split ("Delimiterchar" [, Limitinteger])

Divides the characters in a string by the specified delimiter and uses the resulting substrings to form an array.

SUBSTRING (StartIndex [, EndIndex])

Extracts a substring from the current string. Specify the starting and ending positions.

SUBSTR (StartIndex, [, length])

extracts substrings from the current string, the same as the substring () method. Specifies the starting position and length.

ToString ()

Returns the value of a string.

toLowerCase ()

Returns a string in which all characters in a string are converted to lowercase.

toUpperCase ()

Returns a string in which all characters in a string are converted to uppercase.

ValueOf ()

Returns the value of a string that is the same as the toString () method.

Ways to handle the appearance of strings in Web pages

Big ()

Enlarges the display string.

Blink ()

Causes the string to blink.

Bold ()

Displays the string in bold form.

Fixed ()

Causes the string to appear as a equal-width word.

FontColor (color)

Specifies a color for the string.

FontSize (size)

Sets the size of the string.

Italics ()

Displays the string in italics.

Small ()

Reduces the string font size.

Strike ()

Adds a strikethrough to the string.

Sub ()

Displays the string as a subscript.

SUP ()

Displays the string as superscript.

Ways to convert a string to HTML text

Anchor (Anchor_name)

Used to create an anchor point in a Web page.

var anchor_str = " electronic industry Press ";

document.write (Anchor_str.anchor ("Phei"));

is equivalent to

<a name = "Phei" > Electronics Publishing House </a>

Link (URL)

Adds a hyperlink to a string object.

var str = " Electronic industry publishing house ";

Doument.write (Str.link ("www.phei.com.cn"));

is equivalent to

<a href = "www.phei.com.cn" > Electronics Press </a>

JavaScript built-in object-string

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.