Sobes.tech
Junior — Senior

Impact of null assignment on object reference

livecode

Task condition

Let's analyze what will happen with the console output if we uncomment the line console.log(b). Consider the following code:

const a = {
  a: 'jsdf',
  b: 4
};

const b = [a];

a = null;

Note how changing the variable a affects (or does not affect) the array b, which stored a reference to the object, and what the result will be when trying to output b.