Math.min(Math.max(num, min), max)
I find that the fact that the functions min and max have the same name as the variables min and max increases cognitive load which makes it harder to think about it.<p>I find the following easier to read :<p><pre><code>  Math.min(Math.max(num, lower_bound), upper_bound)</code></pre>