I have a function where if successful, it returns an integer, but if not it just returns false.
Here’s part of my code:
function hellofunc(x) {
//....
if (returnvalue.length == 1) {
return returnvalue[0];
} else if (returnvalue.length > 1) {
return returnvalue[rx(0, returnvalue.length - 1)];
} else {
return false;
}
}
When the function calls this -> return returnvalue[0]; it gives 0 as an integer.
But when I call hellofunc(something); I see it writes to console “0” but when I type something false it returns false,
JavaScript thinks 0 is false? So what do I do here? Do I do this?
hellofunc(something)!==false
Or is there any better solution?
as you said..no better solution..:)