String

This translation is incomplete. Please help translate this article from English

O objeto global String é um construtor de strings ou sequência de carateres.

Sintaxe

Os literais de string assumem as formas:

'string text'
"string text"
"中文 español English हिन्दी العربية português বাংলা русский 日本語 ਪੰਜਾਬੀ 한국어 தமிழ்"

As Strings podem também ser criadas usando o objecto global string directamente:

String(thing)
new String(thing)

Parâmetros

thing
Qualquer parâmetro para ser convertido numa string.

Strings modelo

A partir de ECMAScript 2015, os literais de strings podem também ser chamados de Modelo strings:

`hello world`
`hello!
 world!`
`hello ${who}`
escape `<a>${who}</a>`

Notação Escape

Além dos carateres regulares e imprmiveis, os carateres especiais também podem ser codificados com notação escape:

Código Resultado
\XXX (XXX = 1 - 3 octal digits; range of 0 - 377) ISO-8859-1 character / Unicode code point between U+0000 and U+00FF
\' Aspas simples
\" Aspas duplas
\\ Barra invertida
\n Nova linha
\r carriage return
\v Tab vertical
\t Tab
\b backspace
\f form feed
\uXXXX (XXXX = 4 hex digits; range of 0x0000 - 0xFFFF) UTF-16 code unit / Unicode code point between U+0000 and U+FFFF
\u{X} ... \u{XXXXXX} (X…XXXXXX = 1 - 6 hex digits; range of 0x0 - 0x10FFFF) UTF-32 code unit / Unicode code point between U+0000 and U+10FFFF
\xXX (XX = 2 hex digits; range of 0x00 - 0xFF) ISO-8859-1 character / Unicode code point between U+0000 and U+00FF

Note: Ao contrário de algumas outras linguagens, o Javascript não faz distinção entre strings com aspas simples e aspas duplas; Portanto a notação "escape" funciona em strings independente se foi utilizada aspas simples, ou aspas duplas na criação.

Strings literais longas

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.

Descrição

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.

Acesso de caráter

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.)

Comparação de 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.

Distinção entre string primitivas e objetos String

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 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.

Nota: 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.

Distinção entre string primitivas e objetos String

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
Nota: For another possible approach to strings in JavaScript, please read the article about StringView — a C-like representation of strings based on typed arrays.

Propriedades

String.prototype
Allows the addition of properties to a String object.

Métodos

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.

Instâncias de String

Propriedades

Métodos

Methods unrelated to HTML

HTML wrapper methods

Exemplos

Conversão de String

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]));
}

Especificações

Especificação Estado Comentário
ECMAScript (ECMA-262)
The definition of 'String' in that specification.
Living Standard
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.

Compatibilidade de navegador

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
StringChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
String() constructorChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
anchor
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1
Notes
Full support 1
Notes
Notes Starting with version 17, the quotation mark (") is replaced by its HTML reference character (") in strings supplied for the name parameter.
IE No support NoOpera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
big
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
blink
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
bold
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
charAtChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
charCodeAtChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
codePointAtChrome Full support 41Edge Full support 12Firefox Full support 29IE No support NoOpera Full support 28Safari Full support 10WebView Android Full support 41Chrome Android Full support 41Firefox Android Full support 29Opera Android Full support 28Safari iOS Full support 10Samsung Internet Android Full support 4.0nodejs Full support 4.0.0
Full support 4.0.0
Full support 0.12
Disabled
Disabled From version 0.12: this feature is behind the --harmony runtime flag.
concatChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
endsWithChrome Full support 41Edge Full support 12Firefox Full support 17IE No support NoOpera Full support 28Safari Full support 9WebView Android Full support ≤37Chrome Android Full support 36Firefox Android Full support 17Opera Android Full support 24Safari iOS Full support 9Samsung Internet Android Full support 3.0nodejs Full support 4.0.0
Full support 4.0.0
Full support 0.12
Disabled
Disabled From version 0.12: this feature is behind the --harmony runtime flag.
fixed
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
fontcolor
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
fontsize
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
fromCharCodeChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
fromCodePointChrome Full support 41Edge Full support 12Firefox Full support 29IE No support NoOpera Full support 28Safari Full support 10WebView Android Full support 41Chrome Android Full support 41Firefox Android Full support 29Opera Android Full support 28Safari iOS Full support 10Samsung Internet Android Full support 4.0nodejs Full support 4.0.0
Full support 4.0.0
Full support 0.12
Disabled
Disabled From version 0.12: this feature is behind the --harmony runtime flag.
includesChrome Full support 41Edge Full support 12Firefox Full support 40
Full support 40
No support 18 — 48
Alternate Name
Alternate Name Uses the non-standard name: contains
IE No support NoOpera Full support 28Safari Full support 9WebView Android Full support 41Chrome Android Full support 41Firefox Android Full support 40
Full support 40
No support 18 — 48
Alternate Name
Alternate Name Uses the non-standard name: contains
Opera Android Full support 28Safari iOS Full support 9Samsung Internet Android Full support 4.0nodejs Full support 4.0.0
indexOfChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
italics
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
lastIndexOfChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 6Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
lengthChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
link
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
localeCompareChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 5.5Opera Full support 7Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
localeCompare.localesChrome Full support 24Edge Full support 12Firefox Full support 29IE Full support 11Opera Full support 15Safari Full support 10WebView Android No support NoChrome Android Full support 26Firefox Android No support NoOpera Android No support NoSafari iOS Full support 10Samsung Internet Android Full support 1.5nodejs Full support 13.0.0
Full support 13.0.0
Partial support 0.12
Notes
Notes Before version 13.0.0, only the locale data for en-US is available by default. When other locales are specified, the function silently falls back to en-US. To make full ICU (locale) data available for versions prior to 13, see Node.js documentation on the --with-intl option and how to provide the data.
localeCompare.optionsChrome Full support 24Edge Full support 12Firefox Full support 29IE Full support 11Opera Full support 15Safari Full support 10WebView Android No support NoChrome Android Full support 26Firefox Android No support NoOpera Android No support NoSafari iOS Full support 10Samsung Internet Android Full support 1.5nodejs Full support 0.12
matchChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
matchAllChrome Full support 73Edge Full support 79Firefox Full support 67IE No support NoOpera Full support 60Safari Full support 13WebView Android Full support 73Chrome Android Full support 73Firefox Android Full support 67Opera Android Full support 52Safari iOS Full support 13Samsung Internet Android No support Nonodejs Full support 12.0.0
normalizeChrome Full support 34Edge Full support 12Firefox Full support 31IE No support NoOpera Full support 21Safari Full support 10WebView Android No support NoChrome Android Full support 34Firefox Android Full support 31Opera Android Full support 21Safari iOS Full support 10Samsung Internet Android Full support 2.0nodejs Full support 0.12
padEndChrome Full support 57Edge Full support 15Firefox Full support 48IE No support NoOpera Full support 44Safari Full support 10WebView Android Full support 57Chrome Android Full support 57Firefox Android Full support 48Opera Android Full support 43Safari iOS Full support 10Samsung Internet Android Full support 7.0nodejs Full support 8.0.0
Full support 8.0.0
Full support 7.0.0
Disabled
Disabled From version 7.0.0: this feature is behind the --harmony runtime flag.
padStartChrome Full support 57Edge Full support 15Firefox Full support 48IE No support NoOpera Full support 44Safari Full support 10WebView Android Full support 57Chrome Android Full support 57Firefox Android Full support 48Opera Android Full support 43Safari iOS Full support 10Samsung Internet Android Full support 7.0nodejs Full support 8.0.0
Full support 8.0.0
Full support 7.0.0
Disabled
Disabled From version 7.0.0: this feature is behind the --harmony runtime flag.
rawChrome Full support 41Edge Full support 12Firefox Full support 34IE No support NoOpera No support NoSafari Full support 10WebView Android No support NoChrome Android Full support 41Firefox Android Full support 34Opera Android No support NoSafari iOS Full support 10Samsung Internet Android Full support 4.0nodejs Full support 4.0.0
repeatChrome Full support 41Edge Full support 12Firefox Full support 24IE No support NoOpera Full support 28Safari Full support 9WebView Android No support NoChrome Android Full support 36Firefox Android Full support 24Opera Android Full support 28Safari iOS Full support 9Samsung Internet Android Full support 3.0nodejs Full support 4.0.0
Full support 4.0.0
Full support 0.12
Disabled
Disabled From version 0.12: this feature is behind the --harmony runtime flag.
replaceChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
replaceAllChrome Full support 85Edge Full support 85Firefox Full support 77IE No support NoOpera Full support 71Safari Full support 13.1WebView Android Full support 85Chrome Android Full support 85Firefox Android Full support 79Opera Android Full support 60Safari iOS Full support 13.4Samsung Internet Android No support Nonodejs No support No
searchChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
search.flags
DeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox No support 1 — 49IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support 4 — 49Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
sliceChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
small
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
splitChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
startsWithChrome Full support 41Edge Full support 12Firefox Full support 17IE No support NoOpera Full support 28Safari Full support 9WebView Android Full support ≤37Chrome Android Full support 36Firefox Android Full support 17Opera Android Full support 24Safari iOS Full support 9Samsung Internet Android Full support 3.0nodejs Full support 4.0.0
Full support 4.0.0
Full support 0.12
Disabled
Disabled From version 0.12: this feature is behind the --harmony runtime flag.
strike
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
sub
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
substr
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
substringChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
sup
Deprecated
Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
toLocaleLowerCaseChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 5.5Opera Full support 4Safari Full support 1.3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
toLocaleLowerCase.localeChrome Full support 58Edge Full support 12Firefox Full support 55IE Full support 6Opera Full support 45Safari Full support 10WebView Android Full support 58Chrome Android Full support 58Firefox Android Full support 55Opera Android Full support 43Safari iOS Full support 10Samsung Internet Android Full support 7.0nodejs Full support 13.0.0
Full support 13.0.0
Partial support 0.12
Notes
Notes Before version 13.0.0, only the locale data for en-US is available by default. When other locales are specified, the function silently falls back to en-US. To make full ICU (locale) data available for versions prior to 13, see Node.js documentation on the --with-intl option and how to provide the data.
toLocaleUpperCaseChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 5.5Opera Full support 4Safari Full support 1.3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
toLocaleUpperCase.localeChrome Full support 58Edge Full support 12Firefox Full support 55IE Full support 6Opera Full support 45Safari Full support 10WebView Android Full support 58Chrome Android Full support 58Firefox Android Full support 55Opera Android Full support 42Safari iOS Full support 10Samsung Internet Android Full support 7.0nodejs Full support 13.0.0
Full support 13.0.0
Partial support 0.12
Notes
Notes Before version 13.0.0, only the locale data for en-US is available by default. When other locales are specified, the function silently falls back to en-US. To make full ICU (locale) data available for versions prior to 13, see Node.js documentation on the --with-intl option and how to provide the data.
toLowerCaseChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
toSource
Non-standard
Chrome No support NoEdge No support NoFirefox No support 1 — 74
Notes
No support 1 — 74
Notes
Notes Starting in Firefox 74, toSource() is no longer available for use by web content. It is still allowed for internal and privileged code.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android Full support 4Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
toStringChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
toUpperCaseChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
trimChrome Full support 4Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support 10.5Safari Full support 5WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 5Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
trimEndChrome Full support 66
Full support 66
Full support 4
Alternate Name
Alternate Name Uses the non-standard name: trimRight
Edge Full support 12
Alternate Name
Full support 12
Alternate Name
Alternate Name Uses the non-standard name: trimRight
Firefox Full support 61
Full support 61
Full support 3.5
Alternate Name
Alternate Name Uses the non-standard name: trimRight
IE No support NoOpera Full support 53
Full support 53
Full support 15
Alternate Name
Alternate Name Uses the non-standard name: trimRight
Safari Full support 12WebView Android Full support 66
Full support 66
Full support ≤37
Alternate Name
Alternate Name Uses the non-standard name: trimRight
Chrome Android Full support 66
Full support 66
Full support 18
Alternate Name
Alternate Name Uses the non-standard name: trimRight
Firefox Android Full support 61
Full support 61
Full support 4
Alternate Name
Alternate Name Uses the non-standard name: trimRight
Opera Android Full support 47
Full support 47
Full support 14
Alternate Name
Alternate Name Uses the non-standard name: trimRight
Safari iOS Full support 12Samsung Internet Android Full support 9.0
Full support 9.0
Full support 1.0
Alternate Name
Alternate Name Uses the non-standard name: trimRight
nodejs Full support 10.0.0
Full support 10.0.0
Full support 0.12
Alternate Name
Alternate Name Uses the non-standard name: trimRight
trimStartChrome Full support 66
Full support 66
Full support 4
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
Edge Full support 12
Alternate Name
Full support 12
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
Firefox Full support 61
Full support 61
Full support 3.5
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
IE No support NoOpera Full support 53
Full support 53
Full support 15
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
Safari Full support 12WebView Android Full support 66
Full support 66
Full support ≤37
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
Chrome Android Full support 66
Full support 66
Full support 18
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
Firefox Android Full support 61
Full support 61
Full support 4
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
Opera Android Full support 47
Full support 47
Full support 14
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
Safari iOS Full support 12Samsung Internet Android Full support 9.0
Full support 9.0
Full support 1.0
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
nodejs Full support 10.0.0
Full support 10.0.0
Full support 0.12
Alternate Name
Alternate Name Uses the non-standard name: trimLeft
Unicode code point escapes \u{xxxxxx}Chrome Full support 1Edge Full support 12Firefox Full support 40IE Full support 4Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 40Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
valueOfChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
@@iteratorChrome Full support 38Edge Full support 12Firefox Full support 36
Full support 36
No support 27 — 36
Notes Alternate Name
Notes A placeholder property named @@iterator is used.
Alternate Name Uses the non-standard name: @@iterator
No support 17 — 27
Notes Alternate Name
Notes A placeholder property named iterator is used.
Alternate Name Uses the non-standard name: iterator
IE No support NoOpera Full support 25Safari Full support 9WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 36
Full support 36
No support 27 — 36
Notes Alternate Name
Notes A placeholder property named @@iterator is used.
Alternate Name Uses the non-standard name: @@iterator
No support 17 — 27
Notes Alternate Name
Notes A placeholder property named iterator is used.
Alternate Name Uses the non-standard name: iterator
Opera Android Full support 25Safari iOS Full support 9Samsung Internet Android Full support 3.0nodejs 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.

Consulte também: