Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

244
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda