new Array // outputs []
[] // outputs []
But new Array === []
is false. Why so?
console.log(new Array === [])
new Array // outputs []
[] // outputs []
But new Array === []
is false. Why so?
console.log(new Array === [])
Because they are two different references. They can be two arrays with no elements, but they are two completely different objects on the heap.
Because you are constructing two empty Arrays on each side of the comparison. They are not referring to the same array.