Streaming on Twitch twice a week

Building objects from nested arrays


If you have key-value-pairs in nested arrays, you can turn them into an object with Object.fromEntries().

const pairs = [
  ['name', 'Bob'],
  ['occupation', 'Fry cook'],
  ['shape', 'rectangular']

// ⇒ {
//     name: 'Bob',
//     occupation: 'Fry cook',
//     shape: 'rectangular'
//   }

More fire tips

Replacing all matches in a string

The String prototype’s replace function only replaces the first occurrence of a substring by default. We can extend that with a global flag on the expression.

JavaScriptregular expressions
Read fire tip

Read all fire tips →