26.0k views
16 votes
I need help NOW with my java script!! 1. What will the code below output to the console and why? const person = {

age: 20,
name: 'Ben'
};

const peopleArray = [person, person, person];
peopleArray[1].name = 'Joe';
console.log(peopleArray[0].name);

1 Answer

6 votes

Using a JS console when using the following code:

const person = {

age: 20,

name: "Ben"

};

const peopleArray = [person, person, person];

peopleArray[1].name = 'Joe';

console.log(peopleArray[0].name); (Returns: Joe)

User Russ Huguley
by
4.8k points