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.)


RESETRUNFULL
<!DOCTYPE html><html><body><script>

var o={p1:5,
           "p2":"Ali",
           "":[1,2],                           // arrays can be stored
           "!@":(x)=>{return x;}};  // functions can be storedconsole.log(o.p2);  // Alivar s = "p1";console.log(o[s]);  // 5console.log(o[""]); // [1,2]console.log(o["!@"](10)); // 10

</script></body><html>

Note that [] is a notation for arrays too.