clamping technique (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
mathminmathmax
const min = 0;
const max = 10;
const value = 5;

const result = Math.min(max, Math.max(min, 5));
ready
lodash way
const lower = 0;
const upper = 10;
let number = 5;    

if (number < lower) number = lower
if (number > upper) number = upper

const result = number;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.