Skip to content

YUI

YUI library is a JavaScript library developed by Yahoo.

If you want to enumerate, iterate over, or do a ‘for each’ over all the object properties, you can use the following:

var apple = {
colour: "green",
price: 1.25,
variety: "granny smith",
};
// loop over each property of the apple
// pass in a function that will be called once for each property.
Y.each(apple, function(value, name, obj) {
document.write(name + ": " + value);
});

The function above will be called 3 times and output:

colour: green
price: 1.25
variety: granny smith

Refer to documentation for the YUI Object each function