javascript strings not equal
|

Check Two Strings are NOT Equal in javascript

To check whether two strings are not equal to one another in javascript, use the strict inequality (!==)operator. If the strings are not equal, the strict inequality operator returns true; otherwise, it returns false. In JavaScript, the Not equal operator is represented symbolically by the symbol (!=).

Two Strings are NOT Equal Code examples

console.log('apple' !== 'apple');
// expected output: false

console.log('1' !==  1);
// expected output: true

console.log('' !== '');
// expected output: false

console.log('' !== ' ');
// expected output: true

console.log('' !==  0);
// expected output: true

Unlike the inequality operator, the strict inequality operator always considers operands of different types to be different.

console.log('apple' != 'apple');
// expected output: false

console.log('apple' != 'Apple');
// expected output: true

console.log('1' !=  1);
// expected output: false

console.log('' !=  0);
// expected output: false

console.log('' !=  1);
// expected output: true

Related articles:

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *