Skip to content

Instantly share code, notes, and snippets.

@porfirion
Created June 25, 2015 07:59
Show Gist options
  • Save porfirion/0ff08b6eba4e46c780a7 to your computer and use it in GitHub Desktop.
Save porfirion/0ff08b6eba4e46c780a7 to your computer and use it in GitHub Desktop.
Wrong closure
var test = (function() {
_this = 'test';
return function() {
console.log(_this);
};
})();
(function() {
_this = 'another';
test();
})();
@porfirion
Copy link
Author

This is wrong closure:
_this is interpreted as global variable, because there is no var before _this declaration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment