In the above code snippet we used the simple way of writing program on Not equal to operator in JavaScript. The not equal operator is the exclamation point followed by an equal sign (), and it returns true if operands are not equal. NOTE: The Not equal to operator value can be written as a != 30 or a != "30", both gives the same result.īasic way of using Not equal to operator Other way to write Not equal to operator in JavaScript.ĭocument.getElementById(" myId").innerHTML = c In the above code snippet we have given same values to the variable a and to the not equal operator, so the result give 'false'. If the variable are of the same type, are not numeric, and have the same value, they are considered as equal. If the variable values are of different types, then the values are considered as unequal. In the above code snippet we have given two different values to the variable a and to the not equal operator, so the result gives 'true'.Īssigning same values Assigning 'a' value as 30 and checking the value with '30' in not equal to operator, so the result givesĭocument.getElementById(" myId").innerHTML = ( a != 30) Value are not implicitly converted to some other value before comparison. Assigning different values Assigning 'a' value as 30 and checking the value with '10' in not equal to operator, so the result givesĭocument.getElementById(" myId").innerHTML = ( a != 10) The symbolic representation of Not equal operator in JavaScript is !=. The JavaScript not equal or inequality operator () checks whether two values are not equal and returns a boolean value. If the value of two operands are not equal it returns true. Not equal is an comparison operator which is used to check the value of two operands are equal or not. In the previous post we learnt the Equal opeartor, from this post we are going to learn the Not equal operator in Comparison Operators.
0 Comments
Leave a Reply. |