This question already has an answer here:
I don't know if it's possible duplicate. Testing my code, sometimes I was wrong with because I put =
and not ==
or ===
in if conditions:
Consider this code :
var a = 0;
if(a = 1) console.log('true');
I don't know why this is not an error and why returns true the condition (a = 1) I guess that what it does is assign 1
to the a
variable, but why this evaluates to true and there's no error?
Aucun commentaire:
Enregistrer un commentaire