-
Consider the following code snippet :
var p = counter(), q = counter();
p.count()
q.count()
p.reset()
p.count()
q.count()
The state stored in q is :
-
- Undefined
- Null
- 0
- 1
- None of these
Correct Option: D
Counter function increments the value of the variable by 1 and reset function sets the value of the variable back to 0.as q is incremented twice and reset function is not called on q therefore value of q is 2.