JavaScript only has one numeric type – number – that can be an integer and fractional. Most numbers will be output as base-10 decimals.

See the Pen thecodelog.com - JS Numbers by Deano (@deangilewicz) on CodePen.

There is a difference between number primitives and Number objects. The Number object is a wrapper object that allows methods to be accessed on numerical values. When Number() is used without the new keyword, it can perform type conversion. If the argument cannot be converted into a number, not a number (NaN) is returned.

See the Pen thecodelog.com - JS Numbers 2 by Deano (@deangilewicz) on CodePen.

Be careful, NaN is never equal to another NAN value.

See the Pen thecodelog.com - JS Numbers 3 by Deano (@deangilewicz) on CodePen.

Very large or very small numbers are output by default in exponent form, the same as the output of the toExponential() method.

See the Pen thecodelog.com - JS Numbers 4 by Deano (@deangilewicz) on CodePen.

Binary floating-point numbers have a common gotcha because the representation for 0.1 and 0.2 in binary floating point are not an exact integer but instead really close to the actual integer.

See the Pen thecodelog.com - JS Numbers 5 by Deano (@deangilewicz) on CodePen.

If you need to compare two integers, use a rounding error tolerance value for comparison.

See the Pen thecodelog.com - JS Numbers 6 by Deano (@deangilewicz) on CodePen.