I am absolutely sure that this is impossible, but I would like to know if anyone has brilliant ideas on how to make this possible.
I want the following code to work:
var x = new foo();
x.a.getThis() === x;
In other words, I want to x.a.getThishave a link to thislike xin this case. It makes sense?
To make this work alone , the level is very simple:
function foo(){}
foo.prototype.getThis = function(){ return this; }
var x = new foo();
x.getThis() === x;
One thing, I want this to work as a prototype, not to βcheatβ by manually binding to this:
function foo(){
this.a = {
getThis : (function(){ return this; }).bind(this)
};
}
Although the above is the perfect functional example of what I'm trying to achieve, I just don't want all the extra features for each instance :)
FYI, , Cassandra node, super-column β column-family β foo.a.b foo .