Javascript - String class reference

Introduction

String class works with strings and text.

A JavaScript string stores a series of characters like "test".

A string can be any text inside double or single quotes:

String indexes are zero-based: the first character is in position 0, the second in 1, and so on.

Property

PropertyDescription
String constructor PropertyIn JavaScript, the constructor property returns the constructor function for an object.
String length PropertyThe length property returns the length of a string (number of characters).

Method

MethodDescription
String anchor() MethodThe anchor() method creates an HTML anchor. This method returns the string embedded in the <a> tag, like this:
String big() MethodThe big() method displays a string in a big font. This method returns the string embedded in the <big> tag, like this:
String blink() MethodThe blink() method displays a blinking string. This method returns the string embedded in the <blink> tag, like this:
String bold() MethodThe bold() method is used to display a string in bold. This method returns the string embedded in the <b> tag, like this:
String charAt() MethodThe charAt() method returns the character at the specified index from a string.
String charCodeAt() MethodThe charCodeAt() method returns the Unicode of the character at the specified index in a string.
String concat() MethodThe concat() method can join two or more strings together.
String endsWith() MethodThe endsWith() method determines whether a string ends with a specified string.
String fixed() MethodThe fixed() method can display a string as teletype text.
String fontcolor() MethodThe fontcolor() method can display a string in a specified color.
String fontsize() MethodThe fontsize() method can display a string in a specified size.
String fromCharCode() MethodThe fromCharCode() method converts Unicode values into characters.
String includes() MethodThe includes() method determines whether a string contains the characters of a specified string.
String indexOf() MethodThe indexOf() method returns the position of the first occurrence of a specified value in a string.
String italics() MethodThe italics() method is used to display a string in italic.
String lastIndexOf() MethodThe lastIndexOf() method returns the position of the last occurrence of a specified value in a string.
String link() MethodThe link() method is used to display a string as a hyperlink.
String localeCompare() MethodThe localeCompare() method compares two strings using the current locale.
String match() MethodThe match() method matches a string against a regular expression, and returns the matches, as an Array object.
String repeat() MethodThe repeat() method returns a new string with a specified number of copies.
String replace() MethodThe replace() method matches a string for a specified value, or a regular expression, and returns a new string whose the values are replaced.
String search() MethodThe search() method searches a string for a specified value, and returns the matched position.
String slice() MethodThe slice() method extracts parts of a string and returns the extracted parts as new string.
String small() MethodThe small() method is used to display a string in a small font.
String split() MethodThe split() method can split a string into an array of substrings.
String startsWith() MethodThe startsWith() method checks if a string begins with the specified string.
String strike() MethodThe strike() method displays a string that is struck out.
String sub() MethodThe sub() method displays a string as subscript text.
String substr() MethodThe substr() method returns parts of a string, beginning at the specified position, and returns the specified number of characters.
String substring() MethodThe substring() method extracts the characters from a string, between two specified indices, and returns the new sub string.
String sup() MethodThe sup() method is used to display a string as superscript text.
String toLocaleLowerCase() MethodThe toLocaleLowerCase() method converts a string to lowercase letters, according to the host's current locale.
String toLocaleUpperCase() MethodThe toLocaleUpperCase() method converts a string to uppercase letters, according to the host's current locale.
String toLowerCase() MethodThe toLowerCase() method converts a string to lowercase letters.
String toString() MethodThe toString() method returns the value of a String object.
String toUpperCase() MethodThe toUpperCase() method converts a string to uppercase letters.
String trim() MethodThe trim() method removes whitespace from both sides of a string.
String valueOf() methodThe valueOf() method returns the primitive value of a String object.