Time to ride on some JavaScript WTF with . Number ‘0.0’ When converting a into a , JS is able to . That’s why the get as the result for the first two expressions. String Number interpret a **period** before or after a numeric value as the period of a decimal number 0 Both and represent the decimal . '0.' '.0' 0.0 Here’s the : specification I know. I know. Too much detail! However, “i_f the grammar_ ”, which explains the result for . cannot interpret the String as an expansion of StringNumericLiteral , then the result of ToNumber is NaN . Number('.') i.e. the expression does not match any of the highlighted in the red box above. '.' string literals {} vs [] When is applied to an JavaScript tries to convert it to a . Number Object primitive value By , it first executes . specification .valueOf() Because of both and also return an object, JS tries . .valueOf() {} [] .toString() . The reason for this WTF lies on the result of .toString() The operation actually runs which is . However, as we saw before, converting a String into a Number returns when it cannot be interpret into a numeric value_._ This explains out first result . ({}).toString() Object.prototype.toString() by definition "[object Object]" NaN Number({}) // NaN As for , it executes and outputs . , is . [].toString() Array.prototype.toString() "" By definition Number("") 0 Therefore is . Number([]) 0 👀 Ok! Let’s take a break and watch this kitties undefined vs null According both and represent the absence of something, meaning . ToBoolean null undefined false However, we can see as more generic “absence.” This is because it is used to represent a variable’s value when no other value has been assigned. undefined , undefined a variable has been declared but no formal value has been assigned. , on the other hand, is an . It can be assigned to a variable as a representation of “no value.” null assignment value null, a variable has been declared but has an empty value. Moreover, they have a different . typeof Because of this I came to that this is why is converted into a when executing , meaning . believe undefined NaN Number(undefined) no value assigned And to the value , meaning . null 0 a representation of a value falsy MIN_VALUE It’s easy to understand that is bigger than but it’s weird to realise that is not smaller than . [Number.MAX_VALUE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE) 0 [Number.MIN_VALUE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE) 0 That’s because is not actually the minimum value possible**,** but the , which is a ( to be specific), however bigger than . Number.MIN_VALUE minimum positive value possible very very very small value 5e-324 0 To represent the minimum value possible we can safely use i.e. [Number.MIN_SAFE_INTEGER](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER) -(2^53–1) toFixed() Having a on a numeric value is the way to say that it has a However, this makes the use of inconsistent. period fractional part. static methods For the expression , because the numeric value is a valid number, JS moves forward on interpreting the full expression. However, it finds , which has (as opposed to the expression , which represents the execution of a static method.) and throws a syntax error. 42.toFixed(2) 42. toFixed(2) no meaningful value .toFixed(2) Even a space between and does not solves the problem. 42. toFixed(2) However, a space between and solves the problem. Or even a double period 😮 42 .toFixed(2) 42..toFixed(2) 42.toFixed(2) !== 42..toFixed(2) Nevertheless, this is how JS interprets the code. < your WTF > 👐 If you find any WTF that should be here, please let me know That’s all for Number. Thanks to 🍻 MDN Documentation for his and Kyle Simpson video book All the kitties in the world 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