contain new elements of an "instance" in javascript
- by iamnotmad
Hi, so I know there are tons of ways to simulate inheritance and other OO features. I have chosen one to use for my project and am wondering if I can create an instance and add stuff to it and keep it contained (within braces).
Consider the following:
function BaseClass(){
<this.stuff here>
}
function SubClass(){
this.superClass = BaseClass();
this.superClass();
<this.other stuff here>
}
myObj = new SubClass();
so myObj is an instance of SubClass. I can add things to myObj like:
myObj.blah = "funtimes";
What I would like is to be able to add stuff to the "instance" and keep it organized in braces much like the constructor. psuedo code like:
myObj = new SubClass() {
var blah = "funtimes"
<more instance specific stuff here>
}
Is something like this possible?
Thanks!