flatten

Modified on Fri, 18 Aug 2023

Description

Flatten array a single level deep.

Syntax

flatten(array)

Parameters

Input ParameterTypeDescription
arrayArrayThe array to flatten

Return value

Type
Array<any>

Sample

ExampleResultDescription
flatten([1, [2, 3]])[1, 2, 3]Returns the new flattened array
flatten([1, [2, [3]]])[1, 2, [3]]Returns the new flattened array

To view all the List functions, click here.