const obj = { key: 'value' };obj.key;// Orconst obj = { key: 'value' };obj['key'];
const obj = { 12e34: 'hello' };console.log(obj['1.2e34']); // undefinedconsole.log(obj['1.2e+35']); // 'hello'
const obj = { '12e34': 'hello' };console.log(obj['12e34']); // 'hello'
const styles = { class: 'foo' };// Will throw an exception because class is a reserved keywordstyles[class];// returns 'foo'styles['class'];
-
.