Ted Patrick > { Events & Community } > Adobe Systems


Simple Container without Inheritance

Every once in a while I want a container with no inheritance and with no properties hidden or otherwise. This does the trick.

  Container = function(){
    this.__proto__ = undefined
    delete this.constructor
    delete this.__constructor__
  }

  t = new Container()

It seems that you can modify the inheritance chain by setting this.__proto__ within the constructor. In this case it is set to undefined to provide a block of memory to store information without inheritance.

1 Responses to “ Simple Container without Inheritance ”

  1. # Anonymous Anonymous

    how can i access protected variables in the base class? tnx  

Post a Comment



© 2008 Ted On Flash