Imagine you have a code snippet like this:
dict = {"key":"elem"}
for (var elem in dict){
someFunction(function(){
anotherFunction(dict[elem]);
})
}
Question: Is elem
still considered as the temporary variable created in the for...in...
statement when it is used at that third level, specifically at anotherFunction(dict[elem])
?
Whenever I run this code, I encounter an error indicating that it returns undefined.
EDIT: Can this issue be resolved by incorporating a this
keyword somewhere within the code?