JavaScript if not means simply if the value of two operands are not equal it returns true. You have to use not equal in if/else statement.
How to representation not equal in JS?
Here is symbol representation of not equal !=
.
Note:
!
(negation operator) as “not”,||
(boolean-or operator) as “or”
Example of JavaScript if not equal
1 |
value = !!value; |
Example of a basic way of using Not equal to the operator in JavaScript, if the condition true then the alert box will pop with an actual vale of value1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<!DOCTYPE html> <html> <body> <script language="JavaScript"> value1 = 9 if (value1 != 8) { //if value1 IS NOT equal to 8 this block will be executed alert("value1 is actually " + value1); } </script> </body> </html> |

Do comment if you have any doubts and suggestions on tutorial.
Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version