a = new function() {
this.x=2;
B=function() {
this.y=super.x;
}
this.b=new B();
}
alert(a.b.y); // Expecting 2
In the above, there is a parse error in super. How can I access the value of x when defining the class B?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Found the best way to do this is to pass ‘this’ as the parameter in the constructor of the nested class, like this –