-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
translation(js): Web/JavaScript/Reference/Global_Objects/String/@@ite…
- Loading branch information
1 parent
1fd093a
commit dc33e90
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
files/uk/web/javascript/reference/global_objects/string/@@iterator/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
title: String.prototype[@@iterator]() | ||
slug: Web/JavaScript/Reference/Global_Objects/String/@@iterator | ||
tags: | ||
- ECMAScript 2015 | ||
- Iterator | ||
- JavaScript | ||
- Method | ||
- Prototype | ||
- Reference | ||
- String | ||
- Polyfill | ||
browser-compat: javascript.builtins.String.@@iterator | ||
--- | ||
{{JSRef}} | ||
|
||
Метод **`[@@iterator]()`** повертає новий об'єкт-ітератор, який перебирає кодові точки рядкового значення, повертаючи кожну кодову точку як окремий рядок. | ||
|
||
{{EmbedInteractiveExample("pages/js/string-iterator.html")}} | ||
|
||
## Синтаксис | ||
|
||
```js | ||
str[Symbol.iterator] | ||
``` | ||
|
||
### Повернене значення | ||
|
||
Новий об'єкт-ітератор. | ||
|
||
## Приклади | ||
|
||
### Застосування методу \[@@iterator]\() | ||
|
||
```js | ||
var str = 'A\uD835\uDC68'; | ||
|
||
var strIter = str[Symbol.iterator](); | ||
|
||
console.log(strIter.next().value); // "A" | ||
console.log(strIter.next().value); // "\uD835\uDC68" | ||
``` | ||
|
||
### Застосування методу \[@@iterator]\() з циклом for..of | ||
|
||
```js | ||
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" | ||
``` | ||
|
||
## Специфікації | ||
|
||
{{Specifications}} | ||
|
||
## Сумісність із браузерами | ||
|
||
{{Compat}} | ||
|
||
## Дивіться також | ||
|
||
- Поліфіл методу `String.prototype[@@iterator]` доступний у [`core-js`](https://github.com/zloirock/core-js#ecmascript-string-and-regexp) | ||
- [Протоколи ітерації](/uk/docs/Web/JavaScript/Reference/Iteration_protocols) |