Created
July 23, 2022 10:47
-
-
Save dreygur/edd94fe07078f87166782dcab0397e39 to your computer and use it in GitHub Desktop.
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
| class MyClass { | |
| num = 10; | |
| objects = { | |
| getNum: function() { | |
| return this.num; | |
| }, | |
| setNum: (arg) => { | |
| let oldNum = this.num | |
| this.num = arg; | |
| return [oldNum, this.num]; | |
| } | |
| }; | |
| } | |
| let myObj = new MyClass(); | |
| console.log(myObj.objects.getNum()); | |
| console.log(myObj.objects.setNum(20)); | |
| // What will the above code snippet print to console? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment