delete删除的是构造函数中的属性,不能删除原型对象中的属性
function Foo(){} Foo.prototype.bar = 42; var foo = new Foo(); delete foo.bar; alert(foo.bar); // 42 delete Foo.prototype.bar; // delete it from the prototype Object alert(foo.bar); // undefined
时间: 2024-10-12 01:44:30
delete删除的是构造函数中的属性,不能删除原型对象中的属性
function Foo(){} Foo.prototype.bar = 42; var foo = new Foo(); delete foo.bar; alert(foo.bar); // 42 delete Foo.prototype.bar; // delete it from the prototype Object alert(foo.bar); // undefined