I have a question about the if statement and boolean evaluation in JavaScript.
I create on jsFiddle example of that click, there's four different functions which evaluates the types in array through the loop.
But let's focus only on function b and c.
function b(p) {
return (p == true);
}
function c(p) {
if (p) {
return true;
}
else {
return false;
}
}
As you can see in the console the results are different, for example, -1 and 'Hello' are true to the c, while false in b.
Why that's happens?
Thanks for attention!