a = function(x){
this.c = x;
this.c();
}
a.prototype.b = function () {
alert("B");
}
a.prototype.c = function () {
//overwrite this
}
var z = new a(this.b);
I know using this.b is wrong but is there anyway I can reference an objects method and pass it as an argument when instantiating the object?
I know the object instance doesn't exist yet but the prototypes do.
I can't paste the context as it's far too complicated I'm afraid. Basically I want to overwrite prototype.b on some occasions and do that at the instantiation point rather than afterwards. Mainly for prettier code. But if can't be done no worries.
thisin yourvar z = new a(this.b)is either the globalwindowobject orundefined, replace witha.prototype.balthough it's not clear why you would ever actually want to do this. What are you actually trying to accomplish here?