Function clamp

  • Clamps number within the inclusive lower and upper bounds.

    Parameters

    • num: number

      The number to clamp.

    • Optional lower: number

      The lower bound.

      Optional
    • Optional upper: number

      The upper bound.

      Optional

    Returns number

    Returns the clamped number.

    Since

    5.7.0

    Example

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

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