News for hackers. Stuff that matters.
Re:Math.min(Math.max(num, min), max) by jacobolus on Thursday August 20, 2020 @05:54PM (#24229468)
It’s usually nicer to make a helper function:

  const clamp = (x, low, high) =>
    Math.max(low, Math.min(x, high));
Then it can be easily used later via a descriptive name. e.g.

  color_component = clamp(color_component, 0, 255);

There are no comments on this comment yet.