• Recursively flatten nested arrays

    Parameters

    • arr: any[]

      n-dimensional array

    • result: any[] = []

      Internal use only -- Keeps track of recursion

    Returns any[]

    • Flattened array
    const arr = [
    {label: null, url: '/'},
    {label: 'Model Admin', url: '/model-admin'},
    [
    {label: 'Elements', url: '/model-admin/elements'},
    {label: 'Example', url: null}
    ]
    ];

    console.log(flattenArr(arr));
    // Output:
    [
    {label: null, url: '/'},
    {label: 'Model Admin', url: '/model-admin'},
    {label: 'Elements', url: '/model-admin/elements'},
    {label: 'Example', url: null}
    ]