Home » JavaScript » JavaScript Functions » Question
  1. 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 :
    1. Undefined
    2. Null
    3. 0
    4. 1
    5. 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.



Your comments will be displayed only after manual approval.