JavaScript Strings

Last Updated Jul 29, 2015, 07:00:14 PM





JavaScript Strings

Strings are used to store an manipulate the text in our programs

JavaScript strings stores the simple characters as text

The above example code will store the string called iPhone 5s


Try It Now

The JavaScript string object is most commonly used in the JavaScript. JavaScript string object is used to store and manipulation with text. The String object makes your task easy to store a series of characters and wraps the string primitive data type with some helper methods.

Strings are useful for holding data that can be represented in text form.


Declaration

The string parameter is series of characters that is properly encoded.

JavaScript String Object Methods

Method Description Example
charAt() charAt() method returns the character at the specified index. Try It Now
charCodeAt(x) charCodeAt(x)method returns the Unicode value of the character at position “x” within the string. Try It Now
concat() Combines the text of two strings and returns a new string. Try It Now
indexOf() Returns the first occurance of a character in a string Try It Now
replace() It will find a matched string and replace it with other string Try It Now
search() search for a match between a regular expression and a specified string. Try It Now



Sources and Credits

The source of the content has been referred and updated with Mozilla Developer Network and W3C Organization

Last Updated Jul 29, 2015, 07:00:14 PM



Browser compatibility

Feature
Basic support Yes Yes Yes Yes Yes Yes Yes