The String
global object is a constructor for strings or a sequence of characters.
Syntax
String literals take the forms:
'string text' "string text" "中文 español Deutsch English देवनागरी العربية português বাংলা русский 日本語 norsk bokmål ਪੰਜਾਬੀ 한국어 தமிழ் עברית"
Strings can also be created using the String
global object directly:
String(thing)
Parameters
thing
- Anything to be converted to a string.
Template literals
Starting with ECMAScript 2015, string literals can also be so-called Template literals:
`hello world` `hello! world!` `hello ${who}` tag `<a>${who}</a>`
Escape notation
Besides regular, printable characters, special characters can be encoded using escape notation:
Code | Output |
---|---|
\XXX |
an octal Latin-1 character. |
\' |
single quote |
\" |
double quote |
\\ |
backslash |
\n |
new line |
\r |
carriage return |
\v |
vertical tab |
\t |
tab |
\b |
backspace |
\f |
form feed |
\uXXXX |
unicode codepoint |
\u{X} ... \u{XXXXXX} |
unicode codepoint |
\xXX |
the Latin-1 character |
Unlike some other languages, JavaScript makes no distinction between single-quoted strings and double-quoted strings; therefore, the escape sequences above work in strings created with either single or double quotes.
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.
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.";
Or 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 these result in identical strings being created.
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.
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"
For character access using bracket notation, 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
C developers have the strcmp()
function for comparing strings. In JavaScript, you just use the less-than and greater-than operators:
var a = 'a'; var 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.
Distinction between 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 (i.e., 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.
var s_prim = 'foo'; var 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:
var s1 = '2 + 2'; // creates a string primitive var 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
StringView
— a C-like representation of strings based on typed arrays.Properties
String.prototype
- Allows the addition of properties to a
String
object.
Methods
String.fromCharCode()
- Returns a string created by using the specified sequence of Unicode values.
String.fromCodePoint()
- Returns a string created by using the specified sequence of code points.
String.raw()
- Returns a string created from a raw template string.
String
generic methods
String generics are non-standard, deprecated and will get removed in the near future.
The String
instance methods are also available in Firefox as of JavaScript 1.6 (not part of the ECMAScript standard) on the String
object for applying String
methods to any object:
var num = 15; console.log(String.replace(num, "5", "2"));
For migrating away from String generics, see also Warning: String.x is deprecated; use String.prototype.x instead.
Generics are also available on Array
methods.
String
instances
Properties
String.prototype.constructor
- Specifies the function that creates an object's prototype.
String.prototype.length
- Reflects the length of the string.
N
- Used to access the character in the Nth position where N is an integer between 0 and one less than the value of
length
. These properties are read-only.
Methods
Methods unrelated to HTML
String.prototype.charAt()
- Returns the character (exactly one UTF-16 code unit) at the specified index.
String.prototype.charCodeAt()
- Returns a number that is the UTF-16 code unit value at the given index.
String.prototype.codePointAt()
- Returns a nonnegative integer Number that is the code point value of the UTF-16 encoded code point starting at the specified index.
String.prototype.concat()
- Combines the text of two strings and returns a new string.
String.prototype.includes()
- Determines whether one string may be found within another string.
String.prototype.endsWith()
- Determines whether a string ends with the characters of another string.
String.prototype.indexOf()
- Returns the index within the calling
String
object of the first occurrence of the specified value, or -1 if not found. String.prototype.lastIndexOf()
- Returns the index within the calling
String
object of the last occurrence of the specified value, or -1 if not found. String.prototype.localeCompare()
- Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
String.prototype.match()
- Used to match a regular expression against a string.
String.prototype.matchAll()
- Returns an iterator of all matches.
String.prototype.normalize()
- Returns the Unicode Normalization Form of the calling string value.
String.prototype.padEnd()
- Pads the current string from the end with a given string to create a new string from a given length.
String.prototype.padStart()
- Pads the current string from the start with a given string to create a new string from a given length.
String.prototype.quote()
Wraps the string in double quotes (""
").String.prototype.repeat()
- Returns a string consisting of the elements of the object repeated the given times.
String.prototype.replace()
- Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
String.prototype.search()
- Executes the search for a match between a regular expression and a specified string.
String.prototype.slice()
- Extracts a section of a string and returns a new string.
String.prototype.split()
- Splits a
String
object into an array of strings by separating the string into substrings. String.prototype.startsWith()
- Determines whether a string begins with the characters of another string.
String.prototype.substr()
- Returns the characters in a string beginning at the specified location through the specified number of characters.
String.prototype.substring()
- Returns the characters in a string between two indexes into the string.
String.prototype.toLocaleLowerCase()
- The characters within a string are converted to lower case while respecting the current locale. For most languages, this will return the same as
toLowerCase()
. String.prototype.toLocaleUpperCase()
- The characters within a string are converted to upper case 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 lower case.
String.prototype.toSource()
- Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the
Object.prototype.toSource()
method. 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()
String.prototype.trimLeft()
- Trims whitespace from the beginning of the string.
String.prototype.trimEnd()
String.prototype.trimRight()
- 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
Iterator
object that iterates over the code points of a String value, returning each code point as a String value.
HTML wrapper methods
These methods 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:
var outputStrings = []; for (var i = 0, n = inputValues.length; i < n; ++i) { outputStrings.push(String(inputValues[i])); }
Specifications
Specification | Status | Comment |
---|---|---|
ECMAScript Latest Draft (ECMA-262) The definition of 'String' in that specification. |
Draft | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'String' in that specification. |
Standard | |
ECMAScript 5.1 (ECMA-262) The definition of 'String' in that specification. |
Standard | |
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. |
Browser compatibility
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
String | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
@@iterator | Chrome Full support Yes | Edge Full support Yes | Firefox
Full support
36
| IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile ? | Firefox Android
Full support
36
| Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs Full support 0.12 |
Unicode code point escapes \u{xxxxxx} | Chrome Full support Yes | Edge ? | Firefox Full support 40 | IE ? | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support 40 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
anchor | Chrome Full support Yes | Edge Full support 12 | Firefox
Full support
1
| IE No support No | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
big | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
blink | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
bold | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
charAt | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
charCodeAt | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
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 Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 29 | Opera Android Full support Yes | Safari iOS Full support 10 | Samsung Internet Android Full support Yes | nodejs
Full support
4.0.0
|
concat | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
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 Yes | Chrome Android Full support 36 | Edge Mobile Full support Yes | Firefox Android Full support 17 | Opera Android Full support Yes | Safari iOS Full support 9 | Samsung Internet Android Full support Yes | nodejs
Full support
4.0.0
|
fixed | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
fontcolor | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
fontsize | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
fromCharCode | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
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 Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 29 | Opera Android Full support Yes | Safari iOS Full support 10 | Samsung Internet Android Full support Yes | nodejs
Full support
4.0.0
|
includes | Chrome Full support 41 | Edge Full support 12 | Firefox
Full support
40
| IE No support No | Opera Full support Yes | Safari Full support 9 | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android
Full support
40
| Opera Android Full support Yes | Safari iOS Full support 9 | Samsung Internet Android Full support Yes | nodejs Full support 4.0.0 |
indexOf | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
italics | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
lastIndexOf | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support 6 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
length | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
link | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
localeCompare | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
localeCompare.locales | Chrome Full support 24 | Edge Full support Yes | Firefox Full support 29 | IE Full support 11 | Opera Full support 15 | Safari Full support 10 | WebView Android No support No | Chrome Android Full support 26 | Edge Mobile ? | Firefox Android No support No | Opera Android No support No | Safari iOS Full support 10 | Samsung Internet Android Full support Yes | nodejs ? |
localeCompare.options | Chrome Full support 24 | Edge Full support Yes | Firefox Full support 29 | IE Full support 11 | Opera Full support 15 | Safari Full support 10 | WebView Android No support No | Chrome Android Full support 26 | Edge Mobile ? | Firefox Android No support No | Opera Android No support No | Safari iOS Full support 10 | Samsung Internet Android Full support Yes | nodejs ? |
match | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
match.flags | Chrome No support No | Edge No support No | Firefox No support 1 — 49 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile No support No | Firefox Android No support 4 — 49 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No |
matchAll | Chrome Full support 73 | Edge No support No | Firefox Full support 67 | IE No support No | Opera Full support 60 | Safari No support No | WebView Android Full support 73 | Chrome Android Full support 73 | Edge Mobile No support No | Firefox Android Full support 67 | Opera Android Full support Yes | Safari iOS No support No | Samsung Internet Android Full support Yes | nodejs No support No |
normalize | Chrome Full support 34 | Edge Full support 12 | Firefox Full support 31 | IE No support No | Opera Full support Yes | Safari Full support 10 | WebView Android No support No | Chrome Android Full support 34 | Edge Mobile Full support Yes | Firefox Android Full support 31 | Opera Android Full support Yes | Safari iOS Full support 10 | Samsung Internet Android Full support Yes | 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 | Edge Mobile Full support Yes | 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
|
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 | Edge Mobile Full support Yes | 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
|
prototype | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
quote | Chrome No support No | Edge No support No | Firefox No support 1 — 37 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile No support No | Firefox Android No support 4 — 37 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No |
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 | Edge Mobile Full support Yes | 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 Yes | Safari Full support 9 | WebView Android No support No | Chrome Android Full support 36 | Edge Mobile Full support Yes | Firefox Android Full support 24 | Opera Android Full support Yes | Safari iOS Full support 9 | Samsung Internet Android Full support Yes | nodejs
Full support
4.0.0
|
replace | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
replace.flags | Chrome No support No | Edge No support No | Firefox No support 1 — 49 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile No support No | Firefox Android No support 4 — 49 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No |
search | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
search.flags | Chrome No support No | Edge No support No | Firefox No support 1 — 49 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile No support No | Firefox Android No support 4 — 49 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No |
slice | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
small | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
split | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
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 Yes | Chrome Android Full support 36 | Edge Mobile Full support Yes | Firefox Android Full support 17 | Opera Android Full support Yes | Safari iOS Full support 9 | Samsung Internet Android Full support Yes | nodejs
Full support
4.0.0
|
strike | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
sub | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
substr | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
substring | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
sup | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
toLocaleLowerCase | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
toLocaleLowerCase.locale | Chrome ? | Edge ? | Firefox Full support 55 | IE ? | Opera ? | Safari ? | WebView Android ? | Chrome Android ? | Edge Mobile ? | Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android ? | nodejs ? |
toLocaleUpperCase | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
toLocaleUpperCase.locale | Chrome ? | Edge ? | Firefox Full support 55 | IE ? | Opera ? | Safari ? | WebView Android ? | Chrome Android ? | Edge Mobile ? | Firefox Android Full support 55 | Opera Android ? | Safari iOS ? | Samsung Internet Android ? | nodejs ? |
toLowerCase | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
toSource | Chrome No support No | Edge No support No | Firefox Full support 1 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile 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 Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
toUpperCase | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
trim | Chrome Full support Yes | 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 Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
trimEnd | Chrome
Full support
66
| Edge ? | Firefox
Full support
61
| IE No support No | Opera Full support 53 | Safari ? | WebView Android
Full support
66
| Chrome Android
Full support
66
| Edge Mobile ? | Firefox Android
Full support
61
| Opera Android Full support 47 | Safari iOS ? | Samsung Internet Android
Full support
Yes
| nodejs Full support 10.0.0 |
trimStart | Chrome
Full support
66
| Edge ? | Firefox
Full support
61
| IE No support No | Opera Full support 53 | Safari ? | WebView Android
Full support
66
| Chrome Android
Full support
66
| Edge Mobile ? | Firefox Android
Full support
61
| Opera Android Full support 47 | Safari iOS ? | Samsung Internet Android
Full support
Yes
| nodejs Full support 10.0.0 |
valueOf | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- 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.