JavaScript String Object
String Object
The String object let's you work with text.
Syntax
| var myStr=new String(string); |
String Object Properties
F: Firefox, IE: Internet Explorer
| Property |
Description |
F |
IE |
| constructor |
Returns a reference to the function that created the object |
1 |
4 |
| length |
Returns the number of characters in a string |
1 |
3 |
| prototype |
Allows you to add properties and methods to an object |
1 |
4 |
String HTML Wrapper Methods
The HTML wrapper methods return the string wrapped inside the appropriate
HTML tag.
| Method |
Description |
F |
IE |
| anchor() |
Creates an HTML anchor |
1 |
3 |
| big() |
Creates a string in a big font |
1 |
3 |
| blink() |
Creates a blinking string |
1 |
|
| bold() |
Creates a string in bold |
1 |
3 |
| fixed() |
Creates a string as teletype text |
1 |
3 |
| fontcolor() |
Creates a string in a specified color |
1 |
3 |
| fontsize() |
Creates a string in a specified size |
1 |
3 |
| italics() |
Creates a string in italic |
1 |
3 |
| link() |
Creates a string as a hyperlink |
1 |
3 |
| small() |
Creates a string in a small font |
1 |
3 |
| strike() |
Creates a string with a strikethrough |
1 |
3 |
| sub() |
Creates a string as subscript |
1 |
3 |
| sup() |
Creates a string as superscript |
1 |
3 |
String Object Methods
| Method |
Description |
F |
IE |
| charAt() |
Returns the character at the specified position in a string |
1 |
3 |
| charCodeAt() |
Returns the Unicode of the character at the specified
position in a string |
1 |
4 |
| concat() |
Joins two or more strings |
1 |
4 |
| fromCharCode() |
Converts Unicode values to characters |
1 |
4 |
| indexOf() |
Returns the position of the first found occurrence of a specified value in a string |
1 |
3 |
| lastIndexOf() |
Returns the position of the last found occurrence of a specified value
in a string |
1 |
3 |
| match() |
Searches for a match between a regular expression and a string,
and returns the matches |
1 |
4 |
| replace() |
Searches for a match between a substring (or regular
expression) and a string, and replaces the matched substring with a new
substring |
1 |
4 |
| search() |
Searches for a match between a regular expression and a string,
and returns the position of the match |
1 |
4 |
| slice() |
Extracts a part of a string and returns a new string |
1 |
4 |
| split() |
Splits a string into an array of substrings |
1 |
4 |
| substr() |
Extracts a specified number of characters in a string |
1 |
4 |
| substring() |
Extracts the characters in a string between two specified indices |
1 |
3 |
| toLowerCase() |
Converts a string to lowercase letters |
1 |
3 |
| toUpperCase() |
Converts a string to uppercase letters |
1 |
3 |
| toSource() |
Represents the source code of an object |
1 |
- |
| valueOf() |
Returns the primitive value of a String object |
1 |
4 |
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 4000 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
|