Home / CSE / Javascript - CS :: Discussion

Discussion :: Javascript - CS

  1. Consider the following code snippet

    let x=x+1;

    console.log(x);

    What will be the result for the above code snippet?

  2. A.

     0

    B.

     Null

    C.

     ReferenceError

    D.

     NaN

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    Since x is a let variable and since x is undefined, so x+1 is NaN. Thus, the above code snippet prints NaN.


Be The First To Comment