How to test same object instance in Javascript?

前端 未结 2 1775
孤独总比滥情好
孤独总比滥情好 2021-02-11 19:17

Say I have the following objects in Javascript:

var a = { xxx: 33 };
var b = { xxx: 33 };
var c;

c = a;

What is the Javascript test that will

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-11 19:39

    You just need this

    if(c == a) {
       // same instance
    }
    

    a == b and b == c will return false

提交回复
热议问题