// Here we are declaring a variable called var1
let var1 = {
item: "bat",
sport: "cricket"
};
// Next, we are printing the values of var1 and only its 'item' property without any changes
console.log(var1);
console.log(var1.item);
// Then, we are updating the value of the 'item' property within var1 from "bat" to "ball"
var1.item = "ball";
console.log(var1); // Now we are printing the entire updated var1 object
console.log(var1.item); // And just the 'item' property
The output of running the above lines of code can be viewed here.
I am curious to know why the value of var1 gets updated even when printed before explicitly making a change to var1.item. Can someone provide an explanation for this behavior?