What is an immediately-invoked function expression? evaluates to true if the operand is false and vice-versa. JavaScript Interview Questions and Answers. First is on Boolean value true which returns false, second is on integer value which gets converted into Boolean as true and NOT operation returns false, and the third is value 0 which is treated as false and false is returned. var x = 5; Comparison operators compare two values and give back a boolean value: either true or false. How to write html code dynamically using JavaScript? In the first example, both the expressions will return true and condition will be evaluated as True, In the second example, we have a non-Boolean value which gets converted as true and the return value is the same value itself.
.results { document.getElementById("result1").innerHTML = " !true: " + !true; < evaluates to true if the left operand is less than the right operand. Difference between window, document, and screen in Javascript? Logical operators in JavaScript How to add html elements dynamically with JavaScript? This feature can be used effectively to achieve a better outcome. Here 2 and '2' are the same numbers but the data type is different. !== evaluates to true if the operands are strictly not equal. This is a correction to Gumbo's answer.I'm writing a separate answer only because this won't fit as a comment. What is escape & unescape String functions in JavaScript?