I am sort of new to Javascript and wanting to clear something up, I have read something about Hoisting and feel this might be the reason and answer to my question but why does the log, log out the last assignment to my constant ?
const people = [
{
name: "Roger",
age: 29,
role: "Secret Agent"
},
{
name: "Jamie",
age: 35,
role: "Secret Agent"
}
]
console.log("people", people);
people[0].name = 'bob';
console.log("people", people);
Both results display bob and not Roger then Bob.
It would be great if somebody could explain why this happens.