我正在尝试删除使用原型对象创建的对象。删除似乎不起作用。调用delete之后,对象还在……对象是通过调用创建的:
utils.createWithProto = function (o) {
function F() {}
F.prototype = o;
return new F();
};
以下内容用于创建对象。
// Create a new object using DashboardControl as the prototype
// A unique ID is set in newControl.config.controlId if it was not passed in config
var proto = new DashboardControl(config);
var newControl = Utils.createWithProto(proto);
// Create a collection of Volume models
newControl.volumeCollection = new VolumeCollection();
newControl.volumeCollection.init(newControl.config);
// Create a view
newControl.volumeView = new VolumeView(newControl, newControl.volumeCollection);
我在 volumeCollection 和 volumeView 项目上手动调用 delete,效果很好。但是作为最后一步删除对象本身不起作用:
deleteObject: function(object) {
object.volumeCollection.stop();
delete object.volumeCollection;
object.volumeView.stop();
delete object.volumeView;
//delete object.config;
delete object.prototype;
delete object;
object = null;
}
我该如何删除这个派生对象?