如何从 Javascript 对象中删除所有属性?
例如; 如果我有以下“类”,我该如何执行重置并删除其所有属性:
function MyObject()
{
this.type="blah";
this.name="kkjkj";
}
MyObject.prototype.clearAttribs = function()
{
// I want to remove name, type etc from 'this'
// Maybe I can do the following?
for (var key in this)
delete this[key];
}