O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Viewing the members of an OBJECT using three different methods

The contents of an OBJECT differ from those of an ARRAY. Unlike an array, the keys are not incrementing integers. The values in an object have keys that may be strings or integers or even functions.

Getting ready

Create an object like a hash over which to iterate. Though objects may contain functions, only create string and integer elements for this recipe.

var my_object = {
'one':'one',
'two':2,
3:'Trinity'
};

How to do it...

The iteration of an OBJECT varies from that of an ARRAY in two ways. The first is that the Object.each() class method must be used to begin the iteration, as opposed to iterating using dot concatenation syntax directly as is possible with an ARRAY. Secondly, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required