Javascript casts floating point numbers to integers without cause
问题 I wrote a function that behaves differently depending on the numeric type of it's parameters. Integer or float. Using some code from this question How do I check that a number is float or integer? it was easy to detect if float or not but then I stumbled upon the case that javascript casts 1.0 to 1 without cause if you call a function using that number. Example: function dump(a, b) { console.log(a, typeof b, b); } dump('1', 1); dump('1.0', 1.0); dump('1.1', 1.1); Output chrome, firefox, ie,