• Clamps number within the inclusive lower and upper bounds.

    Parameters

    • number: number

      The number to clamp.

    • Optionallower: number

      The lower bound.

    • upper: number

      The upper bound.

    Returns number

    Returns the clamped number.

    _.clamp(-10, -5, 5);
    // => -5

    _.clamp(10, -5, 5);
    // => 5
    Clamps `number` within the inclusive `lower` and `upper` bounds.
    _.clamp(-10, -5, 5);
    // => -5

    _.clamp(10, -5, 5);
  • Parameters

    • number: number
    • upper: number

    Returns number

    _.clamp