Is there a way to reference the next object up the scope chain in Javascript?
So, for example:
var a = 12;
function run() {
var a = 34;
alert( a ); //replace "a" with something like "parent.a" so it shows 12 instead of 34
}
run();
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.
Nope, there is not. Javascript doesn’t expose the scope chain at all really (much to my chagrin; I’d love to be able to write a function that adds variables to the local scope, but alas I can’t).