以下代码有效,但我是否有导致循环引用或内存泄漏的风险?
/* core package */
var core = function() {
// Throw an error, the core package cannot be instantiated.
throw new Error('A package cannot be instantiated.');
};
core.Container = function (properties){
this.constructor = this;
this.id = null;
if ('id' in properties)
this.id = properties['id'];
else
throw new Error('A container must have an id.');
}
core.Container.prototype = new Object();
var container = new core.Container({'id': 'container'});
alert(container instanceof core.Container); // Result is true