Home | Mailing List | Blog | Tutorial Videos

Function Argument Mutation

When passing an object as an argument to a function, can the orginal object be mutated? In the following example, will somePerson.valid be true or undefined?

const somePerson = { username: 'Davey154' };

const personValidator = person => {
  person.valid = person.username.length > 5;
  return person.valid;
};

personValidator(somePerson);

console.log(somePerson.valid); // ??

Select one: