3 ms·
What is the result of Math.max() is greater than Math.min()
Can someone please explain? I learn something new about JS everyday !
if (Math.min() < Math.max())
console.log("if block?")
else
console.log("or else block?")
- detaro 9y agoWhy don't you just try what their results are and compare them, then it should be obvious why this is true.
- gus_massa 9y agoI think that the implicit question is: Why someone choose this behavior? [spoiler alert] The idea is that if A={a1, a2, ...} B={b1, b2, ...} are sets, then min(union(A, B)) = min(min(A), min(B)) I don't expect this code will not compile as is in any language, but I hope it's understandable enough. The what happens if A is the empty set? if we define x = min(empty) then min(union(empty, B)) = min(B) min(min(empty), min(B)) = min(x, min(B) so min(B) = min(x, min(B)) Then x must be a number big enough to be bigger than min(B) for any set B. But min(B) can be very big if B has only big numbers, so the only possibility is that x = +infinity.
- nlolks 9y agoThe answer is false. Lookup Math.min and Math.max. Min is assigned Ininity Max is assigned -Infinity To test just run the logic on chrome console.