Why is `Object() === new Object()` equal to `false

2019-08-18 01:17发布

问题:

This question already has an answer here:

  • Why are two identical objects not equal to each other? 7 answers

Why it returns false?

let a = new Object()
let b = Object()
console.log(a) // {}
console.log(b) // {}
console.log(a===b) // false

I checked a proto of a and b too and it is the same.

So what is the difference?j

回答1:

Instance of objects are not the same even:

let a = new Object();
let b = new Object();
console.log(a===b) // false