Firebug console scope. Why isn’t “this” always the same? Shoudn’t it be “window” all the time?
Share
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.
The value of
thisin the console will be the same as the value ofthisin the code currently being executed. Consider:-…
If you put a break point on the
x = {n:12}line, switch to console you will find thethisis the window. However when you step to thealertlinethisin the console is the object held by thexvariable. IOW there is no distinction betweenthisin the executing context and the console. Its for this reason that you can use the console to tweak values of variables and properties while debugging.