I often see this in code: var me = this;. Why is that? Is there some performance gain if I reference ‘this’ in local variable?
I often see this in code: var me = this; . Why is that?
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.
It’s useful if there are functions inside a function, such that code in those nested functions needs access to the value of
thisfrom the outer context.Because
thisis established anew for every function call, without stashing the outerthisin a variable there’d be no way to reference it at all from the inner function.