What will be the result of the following code?

console.log(new Number(1) === 1);
In JavaScript any number is an instance of class Number. But if you declare a new object of class Number it may be equal by value to another number but not identical (because they are both completely different objects of class Number). Example:

var a = 1;
var b = new Number(1);
a == b // true;
a === b // false

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback