You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Introduction この記事は最近JavaScriptに入ったGeneratorと呼ばれる機能について知りたい、もっと詳しく知りたいという方をターゲットとしています。 今回はECMAScript 2015に入った機能のgeneratorについて解説していきたいと思います。 generatorはNode界隈では2014年ごろから非同期処理を同期的に書くことができるツールとしてよく使われていました。 最近ではasync/awaitをよく耳にすることがあると思いますが、async/awaitはgeneratorを使ったものに変換可能なので挙動としては近いものと考えてもらって大丈夫です。 ECMAScript Async Functions What is generator 前置き では、generatorとはなんでしょうか?「実はgeneratorはIteratorを返す関数なのです!」
Last week I wrote about the yield return statement in c# and how it allows for deferred execution. In that post I explained how it powers LINQ and explained some non-obvious behaviors. In this week’s post I want to do the same thing but for Javascript. ES6 (ES2015) is becoming more and more mainstream, but in terms of usage I mostly see the more common arrow-functions or block-scoping (with let an
The iterator interface (introduced in ECMAScript 2015) is a sequential data access protocol which enables the development of generic and composable data consumers and transformers. Their primary interface is a next() method which returns a { value, done } tuple, where done is a boolean indicating whether the end of the iterator has been reached, and value is the yielded value in the sequence. Sinc
これは何? ECMA262 6th以降にはiteration protocols(と呼ぶべきもの)が導入されている、というのは皆さんもちろんご存知のとおりだと思います。これを使ってIterator<T>.next()が呼ばれるまでmap()などを実行しない(lazy evaluationする)Iteratorを作ってみようという話です。Rustのstd::iter::IteratorとかC#のLINQとかが似たような挙動をしますよね。 今後、巨大なオブジェクトやリストに対してのIteratorが提供・出現した場合、毎回のように即時評価でfor-ofしたりArray.from()するなどは現実的ではないでしょう。以下のように書くことも出来ますが、 /** * @template T, U * @param {Iterable<T>} src * @param {function(T):U}
A collaborative website about the latest JavaScript features and tools. ECMAScript 2015 (ES6) introduces two new distinct, yet closely related, concepts: iterables and iterators. Now you will truly learn how important these concepts are and how to make good use of them. Iterables Iterable objects are objects that implement the Iterable interface. That is, iterable objects expose a default iterati
class: center, middle, inverse, title-page # Everything is Iterator ### 2015/06/27 #tng16 ### by @teppeis --- # Hello! * Teppei Sato * <a href="https://twitter.com/teppeis">@teppeis</a> <img src="https://secure.gravatar.com/avatar/b593af919ac846342f62d33b32beef2a?s=32" class="avatar"> * Cybozu, Inc. / kintone --- class: wdpress background-image: url(wdpress87.jpg) ??? WEB+DB PRESS Vol.87でES6特集を書きま
This post explains three approaches for extracting information from arrays and objects: for loops, array methods (courtesy of ECMAScript 5 [1]), listing property keys. It concludes with best practices for applying these approaches. for loops All for loops can be used with the following statements. break [label]: exit from a loop. continue [label]: stop the current loop iteration, immediately conti
ES6 In Depth is a series on new features being added to the JavaScript programming language in the 6th Edition of the ECMAScript standard, ES6 for short. How do you loop over the elements of an array? When JavaScript was introduced, twenty years ago, you would do it like this: <pre> for (var index = 0; index < myArray.length; index++) { console.log(myArray[index]); } </pre> Since ES5, you can use
This blog post is outdated. Please read chapter “Iterables and iterators” in “Exploring ES6”. This blog post is part of a series on iteration in ES6: Iterables and iterators in ECMAScript 6 ES6 generators in depth ECMAScript 6 introduces a new interface for iteration, Iterable. This blog post explains how it works, which language constructs consume data via it (e.g., the new for-of loop) and which
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く