1

There are some javascript syntaxes and I didnt understand why they works.

1.

({} === {}) // returns false 

2.

function foo() {
       return
       {
          foo: 'bar'
       }
    }

    function bar() {
       return {
          foo: 'bar'
       }
    }

(typeof foo() === typeof bar()) //return false again

3.

([1,2,3] == [1,2,3]); //very interesting false again
hasan
  • 3,484
  • 1
  • 16
  • 23

1 Answers1

1

In all of these cases, a reference check is performed on the objects on the left and right hand side of the comparison operator. This returns false because although they look the same, they are actually different instances.

Lew
  • 1,248
  • 8
  • 13