Last active
November 18, 2019 15:15
-
-
Save codermarcos/4b6551810322c29ec5bea716b1c2d918 to your computer and use it in GitHub Desktop.
Traditional function not lexical this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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