Number

A number can be obtained by directly using a numeric literal such as 345, or with the Number object. The Number object allows you to convert a string to a number.

Applying a numeric operator on a Number object and a numeric literal yields a value of the number type. Numeric operators include addition(+), subtraction(-), multiplication(*), division(/), remainder(%), and recently exponentiation(**).
console.log(typeof 100);
console.log(typeof new Number(200));

var n = new Number('300');
console.log(typeof n);
console.log(typeof (n ** 2));
console.log(n ** 2);

console.log(new Number("xx"));
console.log(typeof new Number("xx"));

number object object number 90000 NaN object
This shows a few different ways to convert a string to a number.
var s = "1000";
console.log(
  Number(s) +
  parseInt(s) +
  (+s) +
  Math.floor(s) +
  Math.round(s)
);

5000
This tests if a number is an integer (not a float).
n % 1 === 0

Since ECMAScript 2021, an underscore (_) can be used as a numeric separator to visually group digits in a numeric literal, making long numbers easier to read. It has no effect on the value and works with decimal, binary, octal, hexadecimal, and BigInt literals alike. A separator cannot be leading, trailing, doubled-up, or adjacent to a decimal point.


console.log(1_000_000 === 1000000);
console.log(1_000_000.000_1);
console.log(0b1010_0001);   // binary
console.log(0xA0_B0);       // hex
console.log(123_456n);      // BigInt

// console.log(1__000);   // SyntaxError: only one underscore allowed between digits
// console.log(_1000);    // not a numeric separator; parsed as an identifier

true 1000000.0001 161 41136 123456n