Monday, December 12th, 2005
Prototype Meets Ruby: A Look at Enumerable, Array and Hash
<>p>A lot of the open source Ajax frameworks need a bit more on the documentation don’t theyJustin Palmer has gone through and documented some of the features that Prototype adds to your JavaScript experience.
Iterating over an array
someArray.each(function(num) {
logger.info(num);
});
Exposing Hash Key/Value pairs
$H(F.Products[0]).each(function(product) {
logger.info(product.key + ": " + product.value);
});
Collect
var companies = F.Products.collect(function(product) {
return product.company;
});
logger.info(companies.join(', '));
and others such as include, inject, findAll, detect, invoke.
via Thomas Fuchs
Related Content:











Leave a comment