mathue
    Preparing search index...

    Function range

    • Creates a generator that yields numbers in a specified range

      Parameters

      • stop: number

        exclusive bound (sequence stops before reaching this)

      • Optionaloptions: RangeOptions

        optional range configuration

      Returns Generator<number, void, unknown>

      generator yielding numbers from start to stop (exclusive)

      for (const i of range(5)) {
      console.log(i);
      }
      // 0, 1, 2, 3, 4

      for (const i of range(10, { start: 2, step: 2 })) {
      console.log(i);
      }
      // 2, 4, 6, 8

      for (const i of range(0, { start: 10, step: -3 })) {
      console.log(n);
      }
      // 10, 7, 4, 1