JS Utils Kit - v0.5.1
    Preparing search index...

    Function clamp

    • Clamps a number between a minimum and maximum value.

      Ensures that the returned number is not less than min and not more than max.

      Parameters

      • value: number

        The number to clamp.

      • min: number

        The minimum allowed value.

      • max: number

        The maximum allowed value.

      Returns number

      The clamped number.

      clamp(5, 1, 10); // 5
      clamp(0, 1, 10); // 1
      clamp(15, 1, 10); // 10