1.

The snippet that has to be used to check if “a” is not equal to “null” is _________(a) if(a!=null)(b) if (!a)(c) if(a!null)(d) if(a!==null)I got this question in semester exam.My enquiry is from Types, Values and Variables in section Lexical Structures of JavaScript

Answer»

Correct OPTION is (d) if(a!==null)

To EXPLAIN: A strict comparison (e.g., ===) is only true if the OPERANDS are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. The not-equal operator !== compares 0 to null and evaluates to either true or false.



Discussion

No Comment Found

Related InterviewSolutions