Skip to content

Instantly share code, notes, and snippets.

@dreygur
Created July 23, 2022 10:47
Show Gist options
  • Select an option

  • Save dreygur/edd94fe07078f87166782dcab0397e39 to your computer and use it in GitHub Desktop.

Select an option

Save dreygur/edd94fe07078f87166782dcab0397e39 to your computer and use it in GitHub Desktop.
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