Recap

Grade 13, page 12 of 12. A one-minute read.

  • Spread ... unpacks arrays, strings and objects: copying, combining, and passing array items as arguments (Math.max(...nums)).
  • Rest ... packs things up: function f(...args) collects arguments into an array, and const { secret, ...others } = obj collects remaining properties.
  • Destructuring can swap variables ([a, b] = [b, a]), reach into nested data, and work inside for...of loops.
  • Optional chaining ?. stops and returns undefined instead of crashing when something is null or undefined.
  • Nullish coalescing ?? provides a default only for null/undefined. || provides a default for any falsy value (including 0 and "").
  • && and || return one of their actual values, not just true/false. ||=, &&= and ??= combine them with assignment.
  • A Set holds unique values: add, has, delete, size. [...new Set(arr)] removes duplicates.
  • A Map holds key-value pairs with any type of key: set, get, has, delete, size.
  • Date months go from 0 to 11! Subtract dates to get milliseconds. Use toLocaleDateString to display them.

Reading is step one

CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.

Start learning