Stuff I am building:


Ted Patrick - Events & Community @ Adobe Systems


Note: This is the personal blog of Ted Patrick. The opinions and statements voiced here are my own.



Simple Container without Inheritance

DIGG IT!     1 Comments Published Wednesday, June 04, 2003 at 9:29 AM .

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

Where to find me:

Ted on Twitter - @AdobeTed
Ted on Adobe Groups
Ted on LinkedIn
Ted on Facebook
Ted at Adobe


Latest

Lists

Links

Jobs

Flex Jobs
city, state, zip

Archives