Let’s ride on weirdness with JavaScript . Math max() vs min() WHAT? is not bigger than ? 😱 but there’s a reason for it. max min NO returns the largest of the given numbers. However, when no arguments are provided it returns the which is . By definition Math.max([value1[, value2[, ...]]]) minimum possible value, -Infinity As you guessed returns when no arguments are provided, i.e. the . Math.min() Infinity highest possible value Therefore, when comparing is not even fair. Math.max() > Math.min() It’s not fair. its way lower than . -Infinity Infinity 0.1 + 0.2 This is not a problem of JS to be fair. This is . floating point math Computers can only natively store integers, so they need some way of representing decimal numbers. This representation comes with some . That’s why, more often than not, — degree of inaccuracy .1 + .2 != .3 0.300000000000004.com The problem lies on the way machines store numeric values (i.e. .) In the case of , only integers that can be represented as number times the power of two can be exactly represented. binary representation integer values As for (such as , which is ) only values whose the denominator can be represented as a power of two can be exactly represented. rational numbers 0.1 1/10 Although and can be exactly represented in the same is not true for . (which results into a repeating value). 0.1 0.2 base 10 base 2 When this happens our machines create an approximation of their true value Therefore, the result of **0.1 + 0.2** would be a repeating value. Which in is represented by . base 10 0.30000000000000004 [] + {} The operator has a different behaviour in each example. + It behaves as an for the expression , and as for the expression . addition operator [] + {} unary operator {} + [] When interpreting the expression JS identifies an addition operation but before adding both operands it converts them to . This is done by executing the static method . [] + {} primitives .toString() As a result we end up with the operation . '' + '[object Object]' Only at this stage JS knows that the addition operator has the purpose of . And the final value of is returned. + concatenating strings '[object Object]' Next! For the expression , the first operant is a pair of curly brackets (i.e. .) This empty block means . Therefore JS moves forward on executing the expression. {} + [] an empty block “nothing to do” When reaching the operator it behaves as an because it has no left operand. Through is translated into . + unary operator coercion [] 0 true + true Here, the operator behaves as an and adds both operands. However before it can do that it needs to convert them . + additional operator ToNumber , returns if the argument is , if the argument is . By definition ToNumber 1 true 0 false For this reason, our expression translates into , which is 2. true + true 1 + 1 1 < 2 < 3 😎 Spoiler alert: It’s coercion again Here, it may be useful to go step-by-step for both examples. 1 < 2 < 3 Because JS interprets and executes the expressions from , it will run the expression first, therefore ; left to right 1 < 2 true < 3 Next, , which translates into ; coercion ToNumber(true) < 3 1 < 3 Return (because is lower than ); true 1 3 3 > 2 > 1 Because is then ; 3 > 2 true true > 1 translates into ( again 👌); ToNumber(true) > 1 1 > 1 coercion Return (because is not higher than ); false 1 1 ‘5’ + 3 performs either or . By definition the addition operator string concatenation numeric addition . In the case of , because the left operand is a string the final result is the concatenation of both and , which is . When one of the operands is a string, JS converts the other operand to a string and returns the concatenation of both '5' + 3 '5' ToString(3) '53' performs a with the two operands. The subtraction operator subtraction However, when an operator is not of the type it is converted . For that reason, the string is converted into the number to which is subtracted . The final result is . Number ToNumber '5' 5 3 2 < your weirdness > 👐 If you find any weirdness that should be here, please let me know Thanks to 🍻 for her Maggie Neterval talk The mind blowing 0.30000000000000004.com for their — Oracle What Every Computer Scientist Should Know About Floating-Point Arithmetic for his and Kyle Simpson video book MDN Documentation for the and the gifs Chris Pratt Guardians of the Galaxy for publishing ❤️ Hacker Noon Be sure to check out my other articles on JS WTF _Let’s ride on some WTF with JavaScript Arrays._hackernoon.com JS WTF 🦄 with Arrays _Time to ride on some JavaScript WTF with Number._hackernoon.com JS WTF 🦄 with Number