Can you guess what the following expression returns?

10000000000000000 === 10000000000000001

If you guessed true, you’re right! Consider the next example:

10000000000000000 === 10000000000000000.9

This expression also returns true! In JavaScript, 10000000000000001 is not an integer. This is just one of the many missing JavaScript integers. Why are these integers missing, you might ask?

In IEEE floating point type numbers, the larger the number gets, the bigger the gap between numbers. It makes sense when you look at how the number is stored. — Paul²

Further testing reveals many big integers are not present and can be manipulated under the strictly equal to operator.JavaScript Integers TestBy creating a conditional with “missing integers”, we can mislead the user.

if(10000000000000000 !== 10000000000000001) {
// the average person thinks this is executed
} else {
// this is what’s really being executed
}

Check out some examples on jsFiddle.

Thoughts?
~!Donovan

Further Reading:
http://blog.greweb.fr/2013/01/be-careful-with-js-numbers/¹
http://stackoverflow.com/a/10756881/1585455²