This is a simple javascript object. Not a jQuery object, not an array.
Access to the properties of the object will work as follows:
$itemPosition.top; $itemPosition.left;
Placing a $ as the first character of a name is valid, but can be confusing, as this is the convention used when storing a jQuery object.
Another valid way to access the properties of your object is to use square brackets, for example:
$itemPosition['top']; $itemPosition['left'];
Using the square brackets method, you can also pass variables, for example:
var myTopString = 'top'; $itemPosition[myTopString];
If you want to iterate over all the values ββin an object, you can do the following:
for(var n in $itemPosition) { alert( n + ': ' + $itemPosition[n] ); }
This will be the alert() key and value of each property of the object. As you can see, it uses the square bracket method, passing the key for each property stored in variable n .
That is all I have to say about it. -F. Gump
source share