Difference between reference and instance in javascript

后端 未结 8 2078
长情又很酷
长情又很酷 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条回答
  •  梦毁少年i
    2020-12-23 23:29

    Object is an occupied memory for a class. Reference points to that memory and it has got a name (u can call it as a variable). For example, A a = new A(); here when we write "new A();" some memory will be occupied in the system. 'a' is the reference(variable) which points to this memory and is used to access the data present in this memory.

    Object is obtained when it has a life, means it has occupied some memory. Reference points to the Object. Instance is the copy of the Reference that points to object at a point of time.

    Refrence is a variable that points the objects. Object is the instance of the class that have some memory and instance is a variable & methods that object have.

    Reference means address of object or variable. Object is instance of class and instance means representative of class i.e object

    Instance is the actual object created at run time.

提交回复
热议问题