bhylu.com

Advertisements

JS 2019

Flat creates a new array from nested arrays up to a chosen depth. Object.fromEntries builds a record from name-value pairs.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

console.log([[1, 2], [3]].flat());
console.log(Object.fromEntries([["places", 12]]));

What happens

The outputs are a flattened array and a record with places.