Esta tradução está incompleta. Por favor, ajude a traduzir este artigo.

O método [@@iterator]() retorna um novo objeto Iterator que itera sobre os pontos de código do valor da String, retornando cada ponto de código como um valor String.

Sintaxe

str[Symbol.iterator]

Valor de Retorno

Novo objeto Iterator.

Exemplos

Usando [@@iterator]()

var str = 'A\uD835\uDC68';

var strIter = str[Symbol.iterator]();

console.log(strIter.next().value); // "A"
console.log(strIter.next().value); // "\uD835\uDC68"

Usando [@@iterator]() com for..of

var str = 'A\uD835\uDC68B\uD835\uDC69C\uD835\uDC6A';

for (var v of str) {
  console.log(v);
}
// "A"
// "\uD835\uDC68"
// "B"
// "\uD835\uDC69"
// "C"
// "\uD835\uDC6A"

Especificações

  Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'String.prototype[@@iterator]()' in that specification.
Padrão Definição inicial.
ECMAScript Latest Draft (ECMA-262)
The definition of 'String.prototype[@@iterator]()' in that specification.
Rascunho  

Compatibilidade do navegador

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Basic supportChrome Full support YesEdge Full support YesFirefox 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 No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile ? Firefox 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 No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs Full support 0.12

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.
Uses a non-standard name.
Uses a non-standard name.

Veja também

Etiquetas do documento e colaboradores

Colaboradores desta página: vmardss
Última atualização por: vmardss,