Is it possible to remove a function from a constructor?
If the constructor for a Person
object contains a function named greet
, how would one go about eliminating this function?
function Person(name) {
this.name = name;
this.greet = function greet() {
alert("Hello, " + this.name + ".");
};
}
The desired outcome is:
function Person(name) {
this.name = name;
}