Javascript not equal operator
In this article, we will see about Javascript not the equal operator. The symbol “!=” denotes not equal operator in javascript. It is one of the javascript relational operators.
what is relational operator
Relational operators are also known as comparison operators. They are used to find the relationship between two values or compare the relationship between two values; on comparison they yield the result true or false
What is not equal operator
The not equal operator checks the two values are not equal if the two values are not equal the browser returns “true” and If was equal, the browser returns “false“. In this operator, we can check only two values. We should put the “!=” not equal symbol between the two values or variables, Because only then will it check both values.
Example for not equal operator
document.write(5!=5); // false
document.write(5!=8); // true
document.write(5 != "5"); //false
document.write("9" != "5"); // true
- In the above code, we first put the two integer values that are the same and check whether they are different or not using the not equal operator, it returns “false” because the value is the same.
- Then we put different integer values using the not equal operator, it returns “true” because the value is not the same.
- In the next line, we check for string and number with put same number, the integer value and the string value is same so it returns “false”
- finally, we check a string to string using the not equal operator in JS, the integer value and string value are not same so it returns “true.”