The String object is used to represent and manipulate a sequence of characters.
Description
Strings are useful for holding data that can be represented in text form. Some of the most-used operations on strings are to check their length, to build and concatenate them using the + and += string operators, checking for the existence or location of substrings with the indexOf() method, or extracting substrings with the substring() method.
Creating strings
Strings can be created as primitives, from string literals, or as objects, using the String() constructor:
const string1 = "A string primitive"; const string2 = 'Also a string primitive'; const string3 = `Yet another string primitive`;
const string4 = new String("A String object");
String primitives and string objects can be used interchangeably in most situations. See "String primitives and String objects" below.
String literals can be specified using single or double quotes, which are treated identically, or using the backtick character `. This last form specifies a template literal: with this form you can interpolate expressions.
Character access
There are two ways to access an individual character in a string. The first is the charAt() method:
return 'cat'.charAt(1) // returns "a"
The other way (introduced in ECMAScript 5) is to treat the string as an array-like object, where individual characters correspond to a numerical index:
return 'cat'[1] // returns "a"
When using bracket notation for character access, attempting to delete or assign a value to these properties will not succeed. The properties involved are neither writable nor configurable. (See Object.defineProperty() for more information.)
Comparing strings
In C, the strcmp() function is used for comparing strings. In JavaScript, you just use the less-than and greater-than operators:
let a = 'a'
let b = 'b'
if (a < b) { // true
console.log(a + ' is less than ' + b)
} else if (a > b) {
console.log(a + ' is greater than ' + b)
} else {
console.log(a + ' and ' + b + ' are equal.')
}
A similar result can be achieved using the localeCompare() method inherited by String instances.
Note that a == b compares the strings in a and b for being equal in the usual case-sensitive way. If you wish to compare without regard to upper or lower case characters, use a function similar to this:
function isEqual(str1, str2)
{
return str1.toUpperCase() === str2.toUpperCase()
} // isEqual
Upper case is used instead of lower case in this function, due to problems with certain UTF-8 character conversions.
String primitives and String objects
Note that JavaScript distinguishes between String objects and primitive string values. (The same is true of Boolean and Numbers.)
String literals (denoted by double or single quotes) and strings returned from String calls in a non-constructor context (that is, called without using the new keyword) are primitive strings. JavaScript automatically converts primitives to String objects, so that it's possible to use String object methods for primitive strings. In contexts where a method is to be invoked on a primitive string or a property lookup occurs, JavaScript will automatically wrap the string primitive and call the method or perform the property lookup.
let s_prim = 'foo'
let s_obj = new String(s_prim)
console.log(typeof s_prim) // Logs "string"
console.log(typeof s_obj) // Logs "object"
String primitives and String objects also give different results when using eval(). Primitives passed to eval are treated as source code; String objects are treated as all other objects are, by returning the object. For example:
let s1 = '2 + 2' // creates a string primitive
let s2 = new String('2 + 2') // creates a String object
console.log(eval(s1)) // returns the number 4
console.log(eval(s2)) // returns the string "2 + 2"
For these reasons, the code may break when it encounters String objects when it expects a primitive string instead, although generally, authors need not worry about the distinction.
A String object can always be converted to its primitive counterpart with the valueOf() method.
console.log(eval(s2.valueOf())) // returns the number 4
Escape notation
Special characters can be encoded using escape notation:
| Code | Output |
|---|---|
\XXX
(where |
ISO-8859-1 character / Unicode code point between U+0000 and U+00FF
|
\'
|
single quote |
\"
|
double quote |
\\
|
backslash |
\n
|
new line |
\r
|
carriage return |
\v
|
vertical tab |
\t
|
tab |
\b
|
backspace |
\f
|
form feed |
\uXXXX (where XXXX is 4 hex digits; range of 0x0000–0xFFFF)
|
UTF-16 code unit / Unicode code point between U+0000 and U+FFFF
|
\u{X} ... \u{XXXXXX}
(where |
UTF-32 code unit / Unicode code point between U+0000 and U+10FFFF
|
\xXX
(where |
ISO-8859-1 character / Unicode code point between U+0000 and U+00FF
|
Long literal strings
Sometimes, your code will include strings which are very long. Rather than having lines that go on endlessly, or wrap at the whim of your editor, you may wish to specifically break the string into multiple lines in the source code without affecting the actual string contents. There are two ways you can do this.
Method 1
You can use the + operator to append multiple strings together, like this:
let longString = "This is a very long string which needs " +
"to wrap across multiple lines because " +
"otherwise my code is unreadable."
Method 2
You can use the backslash character (\) at the end of each line to indicate that the string will continue on the next line. Make sure there is no space or any other character after the backslash (except for a line break), or as an indent; otherwise it will not work.
That form looks like this:
let longString = "This is a very long string which needs \
to wrap across multiple lines because \
otherwise my code is unreadable."
Both of the above methods result in identical strings.
Constructor
String()- Creates a new
Stringobject. It performs type conversion when called as a function, rather than as a constructor, which is usually more useful.
Static methods
String.fromCharCode(num1 [, ...[, numN)]]- Returns a string created by using the specified sequence of Unicode values.
String.fromCodePoint(num1 [, ...[, numN)- Returns a string created by using the specified sequence of code points.
String.raw()- Returns a string created from a raw template string.
Instance properties
String.prototype.length- Reflects the
lengthof the string. Read-only.
Instance methods
String.prototype.charAt(index)- Returns the character (exactly one UTF-16 code unit) at the specified
index. String.prototype.charCodeAt(index)- Returns a number that is the UTF-16 code unit value at the given
index. String.prototype.codePointAt(pos)- Returns a nonnegative integer Number that is the code point value of the UTF-16 encoded code point starting at the specified
pos. String.prototype.concat(str [, ...strN ])- Combines the text of two (or more) strings and returns a new string.
String.prototype.includes(searchString [, position])- Determines whether the calling string contains
searchString. String.prototype.endsWith(searchString [, length])- Determines whether a string ends with the characters of the string
searchString. String.prototype.indexOf(searchValue [, fromIndex])- Returns the index within the calling
Stringobject of the first occurrence ofsearchValue, or-1if not found. String.prototype.lastIndexOf(searchValue [, fromIndex])- Returns the index within the calling
Stringobject of the last occurrence ofsearchValue, or-1if not found. String.prototype.localeCompare(compareString [, locales [, options)]]- Returns a number indicating whether the reference string
compareStringcomes before, after, or is equivalent to the given string in sort order. String.prototype.match(regexp)- Used to match regular expression
regexpagainst a string. String.prototype.matchAll(regexp)- Returns an iterator of all
regexp's matches. String.prototype.normalize([form])- Returns the Unicode Normalization Form of the calling string value.
String.prototype.padEnd(targetLength [, padString])- Pads the current string from the end with a given string and returns a new string of the length
targetLength. String.prototype.padStart(targetLength [, padString])- Pads the current string from the start with a given string and returns a new string of the length
targetLength. String.prototype.repeat(count)- Returns a string consisting of the elements of the object repeated
counttimes. String.prototype.replace(searchFor, replaceWith)- Used to replace occurrences of
searchForusingreplaceWith.searchFormay be a string or Regular Expression, andreplaceWithmay be a string or function. String.prototype.replaceAll(searchFor, replaceWith)- Used to replace all occurrences of
searchForusingreplaceWith.searchFormay be a string or Regular Expression, andreplaceWithmay be a string or function. String.prototype.search(regexp)- Search for a match between a regular expression
regexpand the calling string. String.prototype.slice(beginIndex[, endIndex])- Extracts a section of a string and returns a new string.
String.prototype.split([sep [, limit] ])- Returns an array of strings populated by splitting the calling string at occurences of the substring
sep. String.prototype.startsWith(searchString [, length])- Determines whether the calling string begins with the characters of string
searchString. String.prototype.substr()- Returns the characters in a string beginning at the specified location through the specified number of characters.
String.prototype.substring(indexStart [, indexEnd])- Returns a new string containing characters of the calling string from (or between) the specified index (or indeces).
String.prototype.toLocaleLowerCase( [locale, ...locales])The characters within a string are converted to lowercase while respecting the current locale.
For most languages, this will return the same as
toLowerCase().String.prototype.toLocaleUpperCase( [locale, ...locales])The characters within a string are converted to uppercase while respecting the current locale.
For most languages, this will return the same as
toUpperCase().String.prototype.toLowerCase()- Returns the calling string value converted to lowercase.
String.prototype.toString()- Returns a string representing the specified object. Overrides the
Object.prototype.toString()method. String.prototype.toUpperCase()- Returns the calling string value converted to uppercase.
String.prototype.trim()- Trims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard.
String.prototype.trimStart()- Trims whitespace from the beginning of the string.
String.prototype.trimEnd()- Trims whitespace from the end of the string.
String.prototype.valueOf()- Returns the primitive value of the specified object. Overrides the
Object.prototype.valueOf()method. String.prototype.@@iterator()- Returns a new
Iteratorobject that iterates over the code points of a String value, returning each code point as a String value.
HTML wrapper methods
Deprecated. Avoid these methods.
They are of limited use, as they provide only a subset of the available HTML tags and attributes.
String.prototype.anchor()<a name="name">(hypertext target)String.prototype.big()<big>String.prototype.blink()<blink>String.prototype.bold()<b>String.prototype.fixed()<tt>String.prototype.fontcolor()<font color="color">String.prototype.fontsize()<font size="size">String.prototype.italics()<i>String.prototype.link()<a href="url">(link to URL)String.prototype.small()<small>String.prototype.strike()<strike>String.prototype.sub()<sub>String.prototype.sup()<sup>
Examples
String conversion
It's possible to use String as a more reliable toString() alternative, as it works when used on null, undefined, and on symbols. For example:
let outputStrings = []
for (let i = 0, n = inputValues.length; i < n; ++i) {
outputStrings.push(String(inputValues[i]));
}
Specifications
| Specification |
|---|
| ECMAScript (ECMA-262)The definition of 'String' in that specification. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
String
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
String() constructor
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox Full support 1 Full support 1 Notes' Starting with version 17, the quotation mark (") is replaced by its HTML reference character ( |
IE
No support No |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
charAt
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
charCodeAt
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
codePointAt
|
Chrome
Full support 41 |
Edge
Full support 12 |
Firefox
Full support 29 |
IE
No support No |
Opera
Full support 28 |
Safari
Full support 10 |
WebView Android
Full support 41 |
Chrome Android
Full support 41 |
Firefox Android
Full support 29 |
Opera Android
Full support 28 |
Safari iOS
Full support 10 |
Samsung Internet Android
Full support 4.0 |
nodejs Full support 4.0.0 Full support 4.0.0 Full support 0.12 Disabled' From version 0.12: this feature is behind the |
concat
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
endsWith
|
Chrome
Full support 41 |
Edge
Full support 12 |
Firefox
Full support 17 |
IE
No support No |
Opera
Full support 28 |
Safari
Full support 9 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 36 |
Firefox Android
Full support 17 |
Opera Android
Full support 24 |
Safari iOS
Full support 9 |
Samsung Internet Android
Full support 3.0 |
nodejs Full support 4.0.0 Full support 4.0.0 Full support 0.12 Disabled' From version 0.12: this feature is behind the |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
fromCharCode
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
fromCodePoint
|
Chrome
Full support 41 |
Edge
Full support 12 |
Firefox
Full support 29 |
IE
No support No |
Opera
Full support 28 |
Safari
Full support 10 |
WebView Android
Full support 41 |
Chrome Android
Full support 41 |
Firefox Android
Full support 29 |
Opera Android
Full support 28 |
Safari iOS
Full support 10 |
Samsung Internet Android
Full support 4.0 |
nodejs Full support 4.0.0 Full support 4.0.0 Full support 0.12 Disabled' From version 0.12: this feature is behind the |
includes
|
Chrome
Full support 41 |
Edge
Full support 12 |
Firefox Full support 40 Full support 40 No support 18 — 48 Alternate Name' Uses the non-standard name: |
IE
No support No |
Opera
Full support 28 |
Safari
Full support 9 |
WebView Android
Full support 41 |
Chrome Android
Full support 41 |
Firefox Android Full support 40 Full support 40 No support 18 — 48 Alternate Name' Uses the non-standard name: |
Opera Android
Full support 28 |
Safari iOS
Full support 9 |
Samsung Internet Android
Full support 4.0 |
nodejs
Full support 4.0.0 |
indexOf
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
lastIndexOf
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 6 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
length
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
localeCompare
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 5.5 |
Opera
Full support 7 |
Safari
Full support 3 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
match
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
matchAll
|
Chrome
Full support 73 |
Edge
Full support 79 |
Firefox
Full support 67 |
IE
No support No |
Opera
Full support 60 |
Safari
Full support 13 |
WebView Android
Full support 73 |
Chrome Android
Full support 73 |
Firefox Android
Full support 67 |
Opera Android
Full support 52 |
Safari iOS
Full support 13 |
Samsung Internet Android
No support No |
nodejs
Full support 12.0.0 |
normalize
|
Chrome
Full support 34 |
Edge
Full support 12 |
Firefox
Full support 31 |
IE
No support No |
Opera
Full support 21 |
Safari
Full support 10 |
WebView Android
No support No |
Chrome Android
Full support 34 |
Firefox Android
Full support 31 |
Opera Android
Full support 21 |
Safari iOS
Full support 10 |
Samsung Internet Android
Full support 2.0 |
nodejs
Full support 0.12 |
padEnd
|
Chrome
Full support 57 |
Edge
Full support 15 |
Firefox
Full support 48 |
IE
No support No |
Opera
Full support 44 |
Safari
Full support 10 |
WebView Android
Full support 57 |
Chrome Android
Full support 57 |
Firefox Android
Full support 48 |
Opera Android
Full support 43 |
Safari iOS
Full support 10 |
Samsung Internet Android
Full support 7.0 |
nodejs Full support 8.0.0 Full support 8.0.0 Full support 7.0.0 Disabled' From version 7.0.0: this feature is behind the |
padStart
|
Chrome
Full support 57 |
Edge
Full support 15 |
Firefox
Full support 48 |
IE
No support No |
Opera
Full support 44 |
Safari
Full support 10 |
WebView Android
Full support 57 |
Chrome Android
Full support 57 |
Firefox Android
Full support 48 |
Opera Android
Full support 43 |
Safari iOS
Full support 10 |
Samsung Internet Android
Full support 7.0 |
nodejs Full support 8.0.0 Full support 8.0.0 Full support 7.0.0 Disabled' From version 7.0.0: this feature is behind the |
raw
|
Chrome
Full support 41 |
Edge
Full support 12 |
Firefox
Full support 34 |
IE
No support No |
Opera
No support No |
Safari
Full support 10 |
WebView Android
No support No |
Chrome Android
Full support 41 |
Firefox Android
Full support 34 |
Opera Android
No support No |
Safari iOS
Full support 10 |
Samsung Internet Android
Full support 4.0 |
nodejs
Full support 4.0.0 |
repeat
|
Chrome
Full support 41 |
Edge
Full support 12 |
Firefox
Full support 24 |
IE
No support No |
Opera
Full support 28 |
Safari
Full support 9 |
WebView Android
No support No |
Chrome Android
Full support 36 |
Firefox Android
Full support 24 |
Opera Android
Full support 28 |
Safari iOS
Full support 9 |
Samsung Internet Android
Full support 3.0 |
nodejs Full support 4.0.0 Full support 4.0.0 Full support 0.12 Disabled' From version 0.12: this feature is behind the |
replace
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
replaceAll
|
Chrome
Full support 85 |
Edge
Full support 85 |
Firefox
Full support 77 |
IE
No support No |
Opera
Full support 71 |
Safari
Full support 13.1 |
WebView Android
Full support 85 |
Chrome Android
Full support 85 |
Firefox Android
Full support 79 |
Opera Android
Full support 60 |
Safari iOS
Full support 13.4 |
Samsung Internet Android
No support No |
nodejs
No support No |
search
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
slice
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
split
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
startsWith
|
Chrome
Full support 41 |
Edge
Full support 12 |
Firefox
Full support 17 |
IE
No support No |
Opera
Full support 28 |
Safari
Full support 9 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 36 |
Firefox Android
Full support 17 |
Opera Android
Full support 24 |
Safari iOS
Full support 9 |
Samsung Internet Android
Full support 3.0 |
nodejs Full support 4.0.0 Full support 4.0.0 Full support 0.12 Disabled' From version 0.12: this feature is behind the |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
substring
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
| Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 | |
toLocaleLowerCase
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 5.5 |
Opera
Full support 4 |
Safari
Full support 1.3 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
toLocaleUpperCase
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 5.5 |
Opera
Full support 4 |
Safari
Full support 1.3 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
toLowerCase
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
| Chrome
No support No |
Edge
No support No |
Firefox No support 1 — 74 No support 1 — 74 Notes' Starting in Firefox 74, |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
Full support 4 |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No |
nodejs
No support No | |
toString
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
toUpperCase
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
trim
|
Chrome
Full support 4 |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 9 |
Opera
Full support 10.5 |
Safari
Full support 5 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 11 |
Safari iOS
Full support 5 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
trimEnd
|
Chrome Full support 66 Full support 66 Full support 4 Alternate Name' Uses the non-standard name: |
Edge Full support 12 Full support 12 Alternate Name' Uses the non-standard name: |
Firefox Full support 61 Full support 61 Full support 3.5 Alternate Name' Uses the non-standard name: |
IE
No support No |
Opera Full support 53 Full support 53 Full support 15 Alternate Name' Uses the non-standard name: |
Safari
Full support 12 |
WebView Android Full support 66 Full support 66 Full support ≤37 Alternate Name' Uses the non-standard name: |
Chrome Android Full support 66 Full support 66 Full support 18 Alternate Name' Uses the non-standard name: |
Firefox Android Full support 61 Full support 61 Full support 4 Alternate Name' Uses the non-standard name: |
Opera Android Full support 47 Full support 47 Full support 14 Alternate Name' Uses the non-standard name: |
Safari iOS
Full support 12 |
Samsung Internet Android Full support 9.0 Full support 9.0 Full support 1.0 Alternate Name' Uses the non-standard name: |
nodejs Full support 10.0.0 Full support 10.0.0 Full support 0.12 Alternate Name' Uses the non-standard name: |
trimStart
|
Chrome Full support 66 Full support 66 Full support 4 Alternate Name' Uses the non-standard name: |
Edge Full support 12 Full support 12 Alternate Name' Uses the non-standard name: |
Firefox Full support 61 Full support 61 Full support 3.5 Alternate Name' Uses the non-standard name: |
IE
No support No |
Opera Full support 53 Full support 53 Full support 15 Alternate Name' Uses the non-standard name: |
Safari
Full support 12 |
WebView Android Full support 66 Full support 66 Full support ≤37 Alternate Name' Uses the non-standard name: |
Chrome Android Full support 66 Full support 66 Full support 18 Alternate Name' Uses the non-standard name: |
Firefox Android Full support 61 Full support 61 Full support 4 Alternate Name' Uses the non-standard name: |
Opera Android Full support 47 Full support 47 Full support 14 Alternate Name' Uses the non-standard name: |
Safari iOS
Full support 12 |
Samsung Internet Android Full support 9.0 Full support 9.0 Full support 1.0 Alternate Name' Uses the non-standard name: |
nodejs Full support 10.0.0 Full support 10.0.0 Full support 0.12 Alternate Name' Uses the non-standard name: |
| Unicode code point escapes \u{xxxxxx} | Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 40 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 40 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
valueOf
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
@@iterator
|
Chrome
Full support 38 |
Edge
Full support 12 |
Firefox Full support 36 Full support 36 No support 27 — 36 Notes' A placeholder property named Notes' A placeholder property named |
IE
No support No |
Opera
Full support 25 |
Safari
Full support 9 |
WebView Android
Full support 38 |
Chrome Android
Full support 38 |
Firefox Android Full support 36 Full support 36 No support 27 — 36 Notes' A placeholder property named Notes' A placeholder property named |
Opera Android
Full support 25 |
Safari iOS
Full support 9 |
Samsung Internet Android
Full support 3.0 |
nodejs
Full support 0.12 |
Legend
- Full support
- Full support
- No support
- No support
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
- See implementation notes.'
- See implementation notes.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
- Uses a non-standard name.'
- Uses a non-standard name.
See also
- Text formatting in the JavaScript Guide
RegExpDOMStringStringView— a C-like representation of strings based on typed arrays- Binary strings
String by Mozilla Contributors is licensed under CC-BY-SA 2.5.