Created
February 17, 2023 21:52
-
-
Save Grubba27/da7cfbd27671b2682cd1c7d8ef6a9808 to your computer and use it in GitHub Desktop.
arrow vs function declaration
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 Module = { | |
| value: 0, | |
| someFn: () => { | |
| return this.value; | |
| }, | |
| okayFn() { | |
| return this.value; | |
| } | |
| } | |
| class Module2 { | |
| value = 0; | |
| someFn = () => { | |
| return this.value; | |
| } | |
| okayFn() { | |
| return this.value; | |
| } | |
| } | |
| console.log( | |
| { | |
| ModuleValues: | |
| { | |
| someFn: Module.someFn(), | |
| okayFn: (Module.add(),Module.okayFn()), | |
| }, | |
| Module2Values: | |
| { | |
| someFn: new Module2().someFn(), | |
| okayFn: new Module2().okayFn(), | |
| } | |
| } | |
| ) | |
| It returns // | |
| /* | |
| { | |
| "ModuleValues": { | |
| "someFn": null, | |
| "okayFn": 0 | |
| }, | |
| "Module2Values": { | |
| "someFn": 0, | |
| "okayFn": 1 | |
| } | |
| } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment