Super simple abstracted example, but I’m wondering if there is a way I can invoke updateAge() from within doMainStuff to update the person object’s age property? Is this where call() or apply() come into play?
function doMainStuff() {
var person = {
name: 'Bob',
age: 55
}
updateAge();
}
function updateAge(){
person.age = 24;
}
You’ll have to pass the
personobject to yourupdateAgefunction: