Objects

JS includes support for objects (HashMap, Dictionary or Structure) Objects consist of key - value pairs. They can be created with the new operator or the preferred object literal syntax:

// using the new operator
var point = new Object();
point.x = 1242;
point.y = 13;
// OR using the object literal syntax
var point = {x: 1242, y: 13};

Values can be retrieved by their key with the bracket [] or dot . operator The bracket operator is required when you would like to dynamically set a key.

alert(point.x);
// OR
alert(point['x']);	
// OR
var theKey = 'x';
alert(point[theKey]);