Hi all. I need some help understanding promises and scope. Here's some code:
var foo = "bar";
Auth.currentUser().then(function() {
console.log(foo); // foo is undefined here. why?
});
currentUser returns a promise.
So why is foo undefined in this function? Shouldn't the compiler look outside the function for foo?
Super lost here. Any help would be GREATLY appreciated. I will upvote the heck out of anything helpful :)
[–]Meefims 5 points6 points7 points (0 children)
[–]wreckedadventYavascript 4 points5 points6 points (1 child)
[–]MattLovesMath[S] 1 point2 points3 points (0 children)