Saturday, November 20, 2010

When we map objects

It is important to note that we are often passing key/value pair objects to jQuery methods. We can often see this when we are passing multple options to a method. FOr example a statement like:


$('div').css({color:'red', padding: '5px'});

Is just a jQuery method (in this case css) that takes key/value mapped pairs. These mapped pairs can be processed even further so that we can use them in functions or widgets.

By mapping objects we can access them by using the period operator (.), which allows us to use the key's associated value. This makes it fairly simple to handle values the same way that we use arrays.

No comments:

Post a Comment