CJCoding With Joseph
← Back to Question List
JavaScript Code Walkthrough #30

Method Mutating this

mediumObjects

📄 Code

Read carefully — what does this print?
1const counter = {
2 value: 10,
3 inc() {
4 this.value++;
5 return this.value;
6 }
7};
8console.log(counter.inc());
9console.log(counter.inc());
10console.log(counter.value);

🎯 Your Answer