MENU
Object
A plain object, o, can be initialized by passing to o an object literal. An object literal is signified by { }. It is a map-like object made up of zero, one or more property:valuepairs separated by commas. Property names are strings and can consist of non-alphanumeric characters. Property values can be accessed by using . or [], as in o.p or o['p']. ([] is more flexible, as variables and strings like “” etc. can also be used to reference the properties.)
var o = {
p1: 5,
"p2": "Ali",
"": [1, 2], // arrays can be stored
"!@": (x) => { return x; } // functions can be stored
};
console.log(o.p2);
var s = "p1";
console.log(o[s]);
console.log(o[""]);
console.log(o["!@"](10));Ali
5
[1,2]
10
Note that [] is a notation for arrays too.