Dev HelpersOpen library
← Back

Es10 Es2019 · code 01

Preserved from the original JavaScript Field Guide. Some entries are React fragments that require the surrounding component.

Open this example in the interactive library

Source code

try {
  // Code that may throw an error
} catch {
  console.log('An error occurred.');
}

const nestedArray = [1, [2, [3, [4, 5]]]];
const flattenedArray = nestedArray.flat(Infinity);
console.log(flattenedArray);
// Output: [1, 2