difference between == and != operators?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our W3Make Forum to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
== is used to check if two values are equal.
ex – a = 5; we assign value of a is 5
sorry for that I accidentally pressed ctrl + enter.
ex a = 5; we assign value of “a’ equal to 5
b=5; same value assign to “b”
a==b;
both ‘a’ and ‘b’ is equal to 5, so the output will be true
With same example ‘a’ and ‘b’ both is equal to 5
a!=b; the output will be false because both ‘a’ and ‘b’ has same value, but if we change the value of ‘b’ to 1.
a=5;
b=1;
a!=b; this will show true, cuz they both have different values.
so basically, the “==” operator is used to check for equality, while the “!=” operator is used to check for inequality.
hope this clears your doubt (: