-4

Ok, I've got an issue I don't understand.

I have a boolean value which I test and if true I do something. BUT javascript never go in it even if the var is true.

I try this :

if(isConfigD)
    handleConfigurationD;

this :

if(isConfigD == true)
    handleConfigurationD;

And this :

if(isConfigD === true)
    handleConfigurationD;

But nothing work whereas isConfigD is always set on true :(

What am I missing ?

Shadam
  • 1,041
  • 13
  • 25
  • 7
    Can you show a larger example of your code? – thepio Sep 14 '16 at 07:33
  • "BUT javascript never go in" --- how do you know that? When debugging, always check the facts, not derivatives from the facts. – zerkms Sep 14 '16 at 07:34
  • @zerkms with the debugger – Shadam Sep 14 '16 at 07:35
  • Possible duplicate of [In JavaScript, does it make a difference if I call a function with parentheses?](http://stackoverflow.com/questions/3246928/in-javascript-does-it-make-a-difference-if-i-call-a-function-with-parentheses) – Thilo Sep 14 '16 at 07:41
  • @Shadam so how could you use debugger and did not see that the function is not called? – zerkms Sep 14 '16 at 07:51
  • @zerkms that was actually my question ;) – Shadam Sep 14 '16 at 08:00
  • @Shadam your question was why the check does not pass: "BUT javascript never go in". Do you seriously not see the difference between what you said and "why is function not called"? – zerkms Sep 14 '16 at 08:02
  • @zerkms the fact was when the debugger stop on `if(isConfigD)` it doesn't go on the line where the `handleConfigurationD;` is. – Shadam Sep 14 '16 at 08:16
  • @Shadam well, that's not true https://jsfiddle.net/kp15rwzr/ Not sure why you think that lying helps, but whatever. – zerkms Sep 14 '16 at 08:19

2 Answers2

6

You condition works well, but if you call a function, then you need parenthesis for the call.

handleConfigurationD();
//                  ^^
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392
1

handleConfigurationD is just an identifier. That statement is going to have one of two outcomes:

  • A ReferenceError
  • "Yup, that's a bit of data"

Presumably you have stored a function in it and want to call the function.

handleConfigurationD();
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335