Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(loop): for...of文について #95

Merged
merged 17 commits into from
Jul 20, 2016
Merged

feat(loop): for...of文について #95

merged 17 commits into from
Jul 20, 2016

Conversation

azu
Copy link
Collaborator

@azu azu commented Jul 20, 2016

  • for...of文
  • iterable
  • 配列もiterable
  • サロゲートペアとfor...of

close #68

サロゲートペアも考慮し1文字ずつ値を列挙することができます。

```js
var string = "吉野家";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"吉野家" じゃない サロゲートペアな文字列欲しい(短めで意味があり、サロゲートペアの例としてよくあがり、商標とかではないもの)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

𩸽 (ホッケ)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azu
Copy link
Collaborator Author

azu commented Jul 20, 2016

𠮷野家はやっぱり強いので、𩸽 (ホッケ)にするかどうかは #96 のMTGに持ち越します。
(𠮷 はやっぱり世界的にも知名度ある気がする https://leanpub.com/understandinges6/read )

実はすでにiterableオブジェクトは登場していて、Arrayはiterableオブジェクトです。

次のようにfor...of文で、配列から値を取り出し反復処理を行うことができます。
for...in文とは異なり、添字ではなく値を列挙します。
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

添字とindexとindex値 迷ってる気がする。
添字だと値っぽい感じがしない

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

添字って聞くと表記法って印象があるけどそうでもないのかな

}
console.log(total); // => 1
```
[import, for-in-array-bug-example.js](./src/for-in/for-in-array-bug-example.js)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for-inの例普通に間違ってた。
サンプルコードを外部ファイルにしてテストを追加した

@azu
Copy link
Collaborator Author

azu commented Jul 20, 2016

loopの節のサンプルコードを外部ファイルにしてテストを追加していってます。

@azu azu merged commit 3a825c6 into master Jul 20, 2016
@azu azu deleted the for-of branch July 20, 2016 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

loop: for/for in/for of/while/do while
2 participants