Library API
    Preparing search index...

    Function toArray

    • Converts an array or array-like object to a new array by numeric index. Bypasses custom [Symbol.iterator] definitions to preserve indexed elements during serialization, and avoids per-element callback closures.

      Type Parameters

      • T

      Parameters

      • Optionalarr: ArrayLike<T> | null

        The array or array-like object to convert

      Returns T[]

      A fresh array containing the indexed elements

      const copy = toArray(['a', 'b']);
      const fromObj = toArray({ 0: 'x', 1: 'y', length: 2 });