The following code works, but am I running the risk of causing circular reference or a memory leak?
/* 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
As posted by @Raynos in chat