Standard built-ins

Number() conversion

Try the free JavaScript compiler

Called without new, Number converts an argument to a Number primitive; invalid numeric text yields NaN. Empty text and null convert to zero; undefined converts to NaN. BigInt can be explicitly converted, potentially losing precision. An omitted argument returns zero.

Formal Syntax & Structure

javascript syntaxjavascript
Number(value)

Parameters & Attributes

NameTypeDescription
valueanyValue to convert; omitted means zero.

Return Value

number

Numeric conversion result, possibly NaN.

Working Example

Example Snippetjavascript
console.log(Number("42"));console.log(Number(""));
JavaScript Reference