|
|
|
|
|
by 0x20cowboy
275 days ago
|
|
I agree with the spirit of this, but I’d go one more step with the example: export function clamp(value: number, min: number, max: number): number {
return
} That is just adding an extra jump and entry on the callstack where you could just have done: Math.min(Math.max(value, min), max); Where you need it. (The example used was probably just for illustration though) |
|
i disagree with this particular example - it's actually a good use case for being a utility maths function in a library.
I mean, the very `min()` and `max()` function you used in the illustration could also have been used as an example, if you use the same logic!