W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2012

An iterable DOM

From: Jason Orendorff <jason.orendorff@gmail.com>
Date: Tue, 19 Jun 2012 16:01:52 -0500
Message-ID: <CAPh8+Zors4CH5k-1RABXy4HXoaS2+0Y=UoRfiWCwnrbVWD2r7g@mail.gmail.com>
To: public-script-coord <public-script-coord@w3.org>
WebIDL should add explicit support for iteration. Many programming
languages have language-level syntactic support for iteration (Python,
Ruby, Java, C++), and it's coming soon to ECMAScript.

ECMAScript is adding a "for...of" loop. Example:
  var languages = ['Python', 'Java', 'C++', 'ES'];
  for (var x of languages)
      alert(x + " has a nice for loop");

Details here:

Arrays are iterable, because there's a new built-in
Array.prototype.iterator method. Many DOM objects should be iterable
too. Certainly those with indexed properties and .length:

  for (var elt of document.querySelectorAll(".post:not(.grouchy)"))

Possibly also dictionaries and DOM iterators.


Received on Tuesday, 19 June 2012 21:02:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:06 UTC