You are almost right. But this will not work because min, and maxin this context refer to?
You either need to specify a qualified identifier:
(flag ? Math.min : Math.max)(a, b)
Or you use the parenthesis syntax and simply specify the name of the property identifier:
Math[flag ? "min" : "max"](a, b)
source
share