Clamps the given value between the given minimum and maximum values.

clamp(10, 0, 5); // 5
clamp(10, 0, 15); // 10
  • Parameters

    • value: number

      number to clamp

    • min: number

      min value

    • max: number

      max value

    Returns number

    clamped value