如何从构造函数中删除函数?
如果构造函数中调用greet
了Person
函数,如何删除该函数?
function Person(name)
{
this.name = name;
this.greet = function greet()
{
alert("Hello, " + this.name + ".");
};
}
我希望结果是:
function Person(name)
{
this.name = name;
}