Question of JavaScript object = null

var obj1 = {test:"hello world"}
var obj2 = obj1
obj1 = null
alert(obj2.test)    // hello world

as far as I understand it, obj1 and obj2 point to the same object. Now obj1 is null,. Why can you still access test? through obj2?

Mar.26,2021

obj1 = null only overrides the direction of obj1, and obj2 still points to the original object, so it can still be accessed.

Menu