Try running the following code:
new scriptObject(myObj) {
class = Stack;
};
If you .dump() the 'myObj' object, you will notice that the "count" variable has automatically been set, and the functions push and pop have been added.
If you run myObj.push(new scriptObject(object).getName());, and dump myObj again, you will notice the following changes:
variable 'count' set to 1
variable 'data0' set to 'object'
Have I said enough yet?