jeudi 24 août 2017

Boolean object is not working properly in condition [duplicate]

This question already has an answer here:

I´m really confused. Maybe anyone can help me? The problem is the following:

var isSignInside = new Boolean(someCondition);

if (!isSignInside) {
    //doStuff
}
else {
    //doOtherStuff
}

Now, if isSignInside is false (the debugger told me), the script still jumps to //doOtherStuff. How can this be? The rest of the snippet isn´t of relevance, but I can share it if asked. Surely there is an easy explanation i don´t see. Thanks in advance. Edit: The someCondition really is a custom method "forced" to return a bool instead of (otherwise) a string.

Aucun commentaire:

Enregistrer un commentaire