in the response from my server I get a JSON object. It has a boolean flag.
if(file.showInTable == 'true') {
}
But, even if showInTable is set to false, I get inside that code block. How to cope with that ?
I tried:
if(file.showInTable == 'true')
if(file.showInTable)
if(Boolean(file.showInTable))
as Ghommey has mentioned, I've used the 2nd option to check that value. Even if the comparions statement returns false, it also gets inside the code. See the pic below

it is set to false or true (as bool) - Tony
Why do you compare a boolean as a string?
Just compare it as a boolean:
if(file.showInTable === true) {
}
or
if(file.showInTable !== false) {
}
This is ugly, but why not?
if (file.showInTable === "false") file.showInTable = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With