Example code below;
function a() {
var a = 123;
//some stuff
b();
}
function b() {
//some stuff
}
a();
So my question is whether the variable ‘a’ is in memory while b() is executed ?
Thank you.
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.
Yes it is. It’s not in
b()‘s scope, but it is in memory.You can’t just magically delete objects withing
a()‘s scope.You could manuallythe best and most reasonable way to do this is by calling them one after the other instead of nested calls:delete a;if you wouldn’t need it anymore, butIf there is not a quick way to do this, consider refactoring your code a bit