Sikau

JavaScript · Day 37 · about 25 min

Reading and updating

Dot and bracket notation.

Change the card

Your friend moves city or has a birthday. Objects can be updated, grow new properties, and lose old ones. Today you'll also meet a second way to read properties: square brackets.

Update, add, delete

const friend = { name: "Pemba", city: "Namche", age: 24 };

friend.age = 25;
friend.job = "guide";
delete friend.city;

console.log(friend);
console.log(friend.city);

The rest of this lesson

  • Bracket notationexplain
  • Objects as lookup tablesexplain
  • Predict the outputpredict
  • Dot or bracket?predict
  • Your turnwrite code
  • Challengechallenge
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 68 lessons of JavaScript