Skip to content

Instantly share code, notes, and snippets.

@codermarcos
Last active November 18, 2019 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codermarcos/4b6551810322c29ec5bea716b1c2d918 to your computer and use it in GitHub Desktop.
Save codermarcos/4b6551810322c29ec5bea716b1c2d918 to your computer and use it in GitHub Desktop.
Traditional function not lexical this
function Mensagem() {
this.mensagem = 'Passou';
// Traditional function
this.loggar = function() {
setTimeout(function() {
console.log(this.mensagem);
}, 0);
};
}
var msg = new Mensagem();
msg.loggar(); // undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment