0

WHY? (not a quiz)

function isFalse() { return false; } console.log(!!isFalse); I'm sorry for not being more clear, it's not a quiz. It's something I don't understand! I don't wanna call the function, I just don't understand why is it true? But if you try "isFalse === true", guess what => false :))

3rd Apr 2020, 7:06 AM
Radu Harangus
Radu Harangus - avatar
6 Respostas
+ 6
!! is a way of getting the boolean value of an expression. !!isFalse is true because you are not calling the function and your are getting the boolean value of the function object called "isFalse". Answer true. Radu Harangus isFalse === true is false because you are comparing a function and a boolean value. === doesn't allow type coercion so it returns false for 2 different types. !!isFalse === true because you are coercing isFalse to a boolean value(true).
3rd Apr 2020, 7:20 AM
Kevin ★
+ 3
Is this something you don't understand or you want to quiz us? If it's a quiz, please post in your personal feed instead. For what, please test in code playground Show me your answer to what, and I'll answer you why
3rd Apr 2020, 7:21 AM
Gordon
Gordon - avatar
0
What do you want?
3rd Apr 2020, 7:08 AM
Shaxzoda Sherzodovna
Shaxzoda Sherzodovna - avatar
0
I'm not sure what your show is about.
3rd Apr 2020, 7:09 AM
Marco
Marco - avatar
0
Yes
3rd Apr 2020, 7:12 AM
Shaxzoda Sherzodovna
Shaxzoda Sherzodovna - avatar
0
you need change console.log(!!isFalse) for console.log(!!isFalse())
3rd Apr 2020, 7:25 AM
Marco
Marco - avatar