Erro javascript if

Question:

I'm not able to make a condition with if for example:

asd=true;
if(asd=='true'){
   alert('funcionou');
}

but it seems that somehow he is not entering the if

Answer:

asd is a boolean value and cannot be treated as a string try the following:

var asd=true;
if(asd==true){
   alert('funcionou');
}

Where

var asd=true;
if(asd){
   alert('funcionou');
}
Scroll to Top