function Foo(){
}
Foo.prototype={
foo:'some text'
,bar:function(){
console.log('Want to be able to retrieve foo of Foo',this.foo);
}
}
var instance=new Foo();
instance.bar.apply({});
Here is link to jsfiddle:
I was trying to play with scopes putting class building inside wrapper with var self
inside it. And after returning instance of Class
, refer it to var self
like that:
function Foo() {
var self;
function Foo_in(){
}
Foo_in.prototype={
foo:'some text'
,bar:function(){
console.log('Want to be able to retrieve foo of Foo',self);
}
}
return self=new Foo_in();
}
var instance=new Foo();
instance.bar.apply({});
Here is link to jsfiddle: http://jsfiddle.net/dnJFt/2/
But my solution is bad, because each time i'm rebuilding Class
and it's prototype methods.
Is there an easier solution?