Question: The following JavaScript code fragments attempt to implement a counter class that hides the counter value c from direct modification. State what each code fragment
The following JavaScript code fragments attempt to implement a counter class that hides the counter value c from direct modification.
State what each code fragment actually achieves. Assume code is executed in strict mode, where variables must be declared before use.
A:
class C constructorc this.inc c; let cnt new C; cntinc c ; cntinc;
B:
class C constructorc this.inc c; Object.freezethis; Object.freezeCprototype; let cnt new C;
C:
class C constructorc inc return c; let cnt new C; cntinc;
D:
class C constructor this.c ; inc return this.c;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
