Created
September 6, 2017 12:59
-
-
Save doug2k1/84347cd94c26c131061625acff5753b9 to your computer and use it in GitHub Desktop.
'this' no JavaScript - https://blog.dmatoso.com/javascript-this-71dd763aad52
This file contains hidden or 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
const player = { | |
name: 'Cloud', | |
sayName () { | |
// Que valor 'this' tem aqui? | |
// Temos que olhar o momento que a função é chamada. | |
console.log(this.name) | |
} | |
} | |
// Dentro da função 'sayName' o 'this' é o que está antes do ponto. | |
// Neste chamada será o 'player'. | |
player.sayName() // Cloud |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment