2

i am getting this strange behaviour from javascript object representation on console and it doesn't make any sense to me

code1:

var list = {
        todo: {task: "one"}
    }

    console.log(list)

    list.todo.task = "two"

chromeconsole

why would console shows me updated value of task ? strangely if i just log the task, it shows me different value

code2:

var list = {
    todo: {task: "one"}
}

console.log(list.todo)

list.todo.task = "two" 

enter image description here

nitesh sharma
  • 591
  • 2
  • 6
  • 16

0 Answers0