Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Is string an object in javascript?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces whether string in javascript is an object or not, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.

In javascript, string is an object, and string objects are used to process text and strings; the creation method of string objects is "var txt = new String (" string ");" or "var txt =" string ";".

This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.

String is an object in javascript.

The String object is used to process text (strings).

The String object creation method: new String ().

Grammar

Var txt = new String ("string")

Or in a simpler way:

Var txt = "string"

String object Properties

The length of the length string referenced by constructor to the function that created the object prototype allows you to add properties and methods to the object

String object method

CharAt () returns the character at the specified position. CharCodeAt () returns the Unicode encoding of the character at the specified position. Concat () concatenates two or more strings and returns a new string. EndsWith () determines whether the current string ends with the specified substring (case sensitive). FromCharCode () converts Unicode encoding to characters. IndexOf () returns the first occurrence of a specified string value in the string. Includes () finds whether the string contains the specified substring. LastIndexOf () searches for the string from back to front and calculates the last occurrence of the returned string starting at the starting position (0). Match () finds a match for one or more regular expressions. Repeat () copies the strings a specified number of times and concatenates them back together. Replace () looks for a matching substring in the string and replaces the substring that matches the regular expression. ReplaceAll () looks for matching substrings in the string and replaces all substrings that match the regular expression. Search () looks for values that match the regular expression. Slice () extracts the fragment of the string and returns the extracted part in the new string. Split () splits the string into an array of strings. StartsWith () checks to see if the string begins with the specified substring. Substr () extracts a specified number of characters from the string from the starting index number. Substring () extracts the character between two specified index numbers in the string. ToLowerCase () converts strings to lowercase. ToUpperCase () converts strings to uppercase. Trim () removes the white space on both sides of the string. ToLocaleLowerCase () converts the string to lowercase based on the locale of the host. ToLocaleUpperCase () converts the string to uppercase based on the locale of the host. ValueOf () returns the original value of a string object. ToString () returns a string.

String HTML packaging method

HTML returns the content contained in the corresponding HTML tag.

The following methods are not standard, so they may not be supported in some browsers.

Anchor () creates a HTML anchor. Big () displays the string in a large font. Blink () displays the flashing string. Bold () displays the string in bold. Fixed () displays the string as typewriter text. Fontcolor () displays the string using the specified color. Fontsize () displays the string using the specified size. Italics () displays strings in italics. Link () displays the string as a link. Small () uses small font sizes to display strings. Strike () is used to display the string with the delete line. Sub () displays the string as a subscript. Sup () displays the string as superscript. Thank you for reading this article carefully. I hope the article "whether string in javascript is an object or not" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report