"!==" what does it mean? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

"!==" what does it mean?

so I am having a hard time what this means: return ( number % 2 !== 0); mostly with the" !==". does it function the same way as "=" and "=="? so for example: (number % 2 !== 0) console.log(2); so would it be ( 2 % 2 !==0) the output should be 0. I am a bit confused, please help! thank you.

20th Mar 2023, 1:47 AM
Eren
5 Answers
+ 4
In JavaScript, the "!=="" operator is used for strict inequality comparison, which means that it compares two values and returns a Boolean value based on whether they are not equal in value or data type. In the context of the code you provided, "(number % 2 !== 0)" means that it checks whether the remainder of the division of "number" by 2 is not equal to zero. If the remainder is not equal to zero, then it returns true; otherwise, it returns false.
20th Mar 2023, 1:54 AM
Minh Lưu
Minh Lưu - avatar
20th Mar 2023, 4:53 AM
Sakshi
Sakshi - avatar
+ 1
In python it is similar Operator Meaning Example ==Is Equal To 3 == 5 gives us False !=Not Equal To 3 != 5 gives us True
20th Mar 2023, 2:54 AM
Herobrine
Herobrine - avatar
+ 1
To understand what !== means you first need to know what === is. In javascript if you use == in an if condition to compare between "1" and 1 then it will return true. Even though they are different value types they still are equal. But === (Strict equality) not only checks if two values are equal but also if they are the SAME type. For example if you compare 1 and "1" with === then it will return false but if you compare 1 and 1 or "1" and "1" with === then it will return true !== is exactly like === but the catch is... if it becomes true then it returns false and if it is false then it returns true. So 1 and 1 compared with !== will return false while 1 and 2 return true... same thing when compared with "1" and 1.
21st Mar 2023, 10:32 AM
Dronto
Dronto - avatar
0
Eren It is used for inequality comparison ....
21st Mar 2023, 3:34 PM
Abhishek