I have declared the following object:
const restaurant = {
openingHours: {
thu: {
open: 12,
close: 22,
},
fri: {
open: 11,
close: 23,
},
saturday: {
open: 0, // Open 24 hours
close: 24,
},
}
};
than i desturctured openingHours object into a new variable name friday:
const { fri: friday } = restaurant.openingHours;
than i modified the value of open hour property in friday object:
friday.open = 5;
and in the end i checked if the change affect original restaurant property:
console.log(restaurant.openingHours.fri.open, friday.open); // prints 5 5
I can't understand why it change the value of restaurant.openingHours.fri.open to 5?
Cause if i had the following code:
let originalAge =5;
let newAge = originalAge;
newAge =6;
console.log(originalAge) // will print 5, So what is the difference here?