Created
June 9, 2019 18:46
-
-
Save fortunee/c6f1923081e04d4abe3c652116659abf to your computer and use it in GitHub Desktop.
The sixth rule of javascript this keyword example
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
// Rule #6 example (arrow functions) | |
function RuleSix() { | |
this.value = 'Some value for rule #6'; | |
this.printValue = () => { | |
console.log('Rule six value >>>>', this.value); | |
} | |
} | |
const ruleSix = new RuleSix(); | |
const printRuleSixVal = ruleSix.printValue; | |
// the this of parent scope is still in use unlike in RuleThree eg | |
printRuleSixVal(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment