I don't understand why are there no () after changeName on this line this.chngName = changeName;
. My logic is that this.chngName
gets assigned to a function return and the functions have a () at the end. Thanks for answering.
function person(firstname, lastname, age, eyecolor) {
this.firstname = firstname;
this.lastname = lastname;
this.age = age;
this.eyecolor = eyecolor;
this.chngName = changeName;
function changeName(name) {
this.lastname = name;
}
}
myMother = new person("Sally", "Rally", 48, "green");
myMother.chngName("Doe");
document.write(myMother.lastname);