rgrove / jquery-yui3-rosetta-stone

A guide to idioms in YUI 3 and jQuery.
BSD 3-Clause "New" or "Revised" License
65 stars 20 forks source link

map() example #19

Open benjamincochran opened 12 years ago

benjamincochran commented 12 years ago

YUI has a less cumbersome map feature than the example, that isn't restricted to nodes:

// Convert an array of numbers into an array of strings.
Y.Array.map([1, 2, 3, 4], function (item) {
  return '' + item;
});
// => ['1', '2', '3', '4']

So in the context of the example given, this could be a one-liner:

Y.Array.map(Y.all('a').getDOMNodes(), some_function);
rgrove commented 12 years ago

Thanks! Care to turn this into a pull request?