Ross Cooper's blog

The non-adventures of Ross, Sally & Boo

  • Blog
  • Monkeys
  • iPhone Apps
« Back to posts
  • Viewed
    times

Filed under

  • code
March 14, 2009

Prototype Enumerable

  • Edit
  • Delete
  • Tags
  • Autopost
In the previous post, I iterated over an array with the following code...
var ids=new Array('1','2');for (var i=0;i<ids.length;i++) $(ids[i]).style.display = 'none';
You can do this in one line of code using prototype's Enumerable.each method...
['1','2'].each(function(id,index) {$(id).style.display = 'none';});
Tweet
  • 0 responses
  • Like
  • Comment