Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
what is the difference between (!a==b) and (a != b) in JS?
if(openmenu != para){
addClass(openmenu , 'collapsed');
}

I am a beginner of JS, I want to add a classname to a element after a if statement. However, if(openmenu != para) and if(!openmenu == para) showed completely different result. Does anyone know why?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

!openmenu == para is parsed as (!openmenu) == para, so it first negates openmenu and then checks whether it is equal to para, which is most likely not what you want to do. You could write !(openmenu == para) which would mean the same thing as openmenu != para.

about 4 years ago · Juan Pablo Isaza Report

0

!a == b inverts a's value. For example if it's true, using ! will invert it to false.

if(!true == false) equals to if(false == false) which results as true.

but if(a != b) compares values, lets say a is true and b is false, so if(true == false) => false values are not the same. :)

about 4 years ago · Juan Pablo Isaza Report

0

In this case, if a==null and b==false so !a = true.

Then !a == b is false but a!=b is true. I hope that answer is helpful to you.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!