Function clamp

  • Clamps number within the inclusive lower and upper bounds.

    Parameters

    • number: number

      The number to clamp.

    • lower: number

      The lower bound.

    • upper: number

      The upper bound.

    Returns number

    Returns the clamped number.

    4.0.0

    clamp(-10, -5, 5)
    // => -5

    clamp(10, -5, 5)
    // => 5