@jiminp/tooltool
    Preparing search index...

    Function range

    • Creates a lazy generator yielding a sequence of numbers or bigints (like Python's range()).

      • range(end)[0, end)
      • range(start, end)[start, end)
      • range(start, end, step)[start, end) with custom step

      Default step is 1 (or 1n). For descending ranges, provide a negative step.

      Parameters

      • start: number

        Start of sequence (or end if only one argument).

      • Optionalend: number

        End of sequence (exclusive).

      • Optionalstep: number

        Increment (default: 1 or 1n).

      Returns Generator<number>

      A Generator yielding the sequence.

      If step is 0 or 0n.

      Floating-point arguments may cause imprecise results due to accumulation errors. Use integers for reliable sequences.

      [...range(5)];           // [0, 1, 2, 3, 4]
      [...range(5, 10)]; // [5, 6, 7, 8, 9]
      [...range(0, 10, 2)]; // [0, 2, 4, 6, 8]
      [...range(5, 0, -1)]; // [5, 4, 3, 2, 1]
      [...range(0n, 5n)]; // [0n, 1n, 2n, 3n, 4n]
    • Creates a lazy generator yielding a sequence of numbers or bigints (like Python's range()).

      • range(end)[0, end)
      • range(start, end)[start, end)
      • range(start, end, step)[start, end) with custom step

      Default step is 1 (or 1n). For descending ranges, provide a negative step.

      Parameters

      • start: bigint

        Start of sequence (or end if only one argument).

      • Optionalend: bigint

        End of sequence (exclusive).

      • Optionalstep: bigint

        Increment (default: 1 or 1n).

      Returns Generator<bigint>

      A Generator yielding the sequence.

      If step is 0 or 0n.

      Floating-point arguments may cause imprecise results due to accumulation errors. Use integers for reliable sequences.

      [...range(5)];           // [0, 1, 2, 3, 4]
      [...range(5, 10)]; // [5, 6, 7, 8, 9]
      [...range(0, 10, 2)]; // [0, 2, 4, 6, 8]
      [...range(5, 0, -1)]; // [5, 4, 3, 2, 1]
      [...range(0n, 5n)]; // [0n, 1n, 2n, 3n, 4n]