Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 490 Bytes

File metadata and controls

35 lines (25 loc) · 490 Bytes


Properties

  • 12.1 Use dot notation when accessing properties.
const luke = {
  jedi: true,
  age: 28,
};

// bad
const isJedi = luke['jedi'];

// good
const isJedi = luke.jedi;
  • 12.2 Use subscript notation [] when accessing properties with a variable.
const luke = {
  jedi: true,
  age: 28,
};

function getProp(prop) {
  return luke[prop];
}

const isJedi = getProp('jedi');