Sikau

JavaScript · Day 40 · about 30 min

Unpacking and JSON

Destructuring, spread and saving data.

Handy modern tools

Three tools that make working with objects and arrays smoother: unpacking values into variables, spreading them into copies, and JSON — the format the whole internet uses to send data.

Destructuring

const trek = { name: "Annapurna Circuit", days: 14, maxHeight: 5416 };

const { name, days } = trek;
console.log(name, days);

const [first, second] = ["gold", "silver", "bronze"];
console.log(first, second);

The rest of this lesson

  • Spread: copy and combineexplain
  • JSON: data as textexplain
  • Copies, not changesexplain
  • Predict the outputpredict
  • Round trippredict
  • 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