Answer the question
In order to leave comments, you need to log in
How to reference current object from object in js prototype?
function JClass() {
var t = 1;
};
JClass.prototype.option = {
newo:function(){
alert(/*Как здесь сослаться на t текущего объекта*/);
}
};
new JClass().option.newo(); // Должен вывести значение t
Answer the question
In order to leave comments, you need to log in
It's easiest to do this:
function JClass() {
this.t = 1;
};
alert((new JClass()).t);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question