Javascript Number constructor

Introduction

The Javascript Number() constructor creates a Number object.

new Number(value)
Parameter Optional Meaning
value RequiredThe numeric value of the object being created.
const a = new Number('123'); // a === 123 is false
console.log(a);//from  www .  ja va  2  s.c  o  m
const b = Number('123');     // b === 123 is true
console.log(b);
console.log(a instanceof Number);
console.log(b instanceof Number);



PreviousNext

Related