Sobes.tech
Intern — Senior

What will be displayed in the console after changing a property through an object copy

livecode

Task condition

Determine which values will be printed to the console after executing the given code. Note that the variable copyObj references the same object as sourceObj, so changing a property through one variable will reflect on the other.

const sourceObj = {
  name: 'Максим'
}
const copyObj = sourceObj
copyObj.name = 'Андрей'

console.log(sourceObj)
console.log(copyObj)