Difference between reference and instance in javascript

后端 未结 8 2081
长情又很酷
长情又很酷 2020-12-23 23:10

Sometimes I hear people say \"a reference to a object\" and some say \"a instance of a object\" What is the difference?

8条回答
  •  死守一世寂寞
    2020-12-23 23:33

    There can be many references to one instance. It's like, um, many paths leading to the same place.

    var x="string object";
    var y=x;
    

    Both x and y are two different (but equal) references to the same instance of an object.

提交回复
热议问题