Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
Creating Numbers
A number value can be generated using a number literal syntax:
const age = 36
typeof age //number
or using the Number global function:
const age = Number(36)
typeof age //number
If we add the new keyword, we get a Number object in return:
const age = new Number(36)
typeof age //object
which has a very different behavior than a number type. You can get the original number value using the valueOf() method:
const age = new Number(36)
typeof age //object
age.valueOf() //36
Number Properties
The Number object has several useful properties:
EPSILONthe smallest interval between two numbersMAX_SAFE_INTEGERthe maximum integer value JavaScript can representMAX_VALUEthe maximum positive value JavaScript can representMIN_SAFE_INTEGERthe minimum integer value JavaScript can representMIN_VALUEthe minimum positive value JavaScript can representNaNa special value representing “not a number”NEGATIVE_INFINITYa special value representing negative infinityPOSITIVE_INFINITYa special value representing positive infinity
Those properties evaluated to the values listed below:
Number.EPSILON //2.220446049250313e-16
Number.MAX_SAFE_INTEGER //9007199254740991
Number.MAX_VALUE //1.7976931348623157e+308
Number.MIN_SAFE_INTEGER //-9007199254740991
Number.MIN_VALUE //5e-324
Number.NaN //NaN
Number.NEGATIVE_INFINITY //-Infinity
Number.POSITIVE_INFINITY //Infinity
Safe Integers
A safe integer is an integer that can be exactly represented as an IEEE-754 double precision number (all integers from (2^53 - 1) to -(2^53 - 1)). Out of this range, integers cannot be represented by JavaScript correctly.
NaN
NaN is a special value that represents “Not a Number”. It’s returned when a mathematical operation doesn’t result in a valid number:
0 / 0 //NaN
Math.sqrt(-1) //NaN
parseInt('hello') //NaN
NaN has the unique property of not being equal to itself:
NaN === NaN //false
Use Number.isNaN() to check if a value is NaN.
Infinity
JavaScript has special values for positive and negative infinity:
1 / 0 //Infinity
-1 / 0 //-Infinity
You can check for infinity using Number.isFinite().
valueOf() Method
This method returns the number value of a Number object:
const age = new Number(36)
typeof age //object
age.valueOf() //36