Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is double exclamation sign(!!) is equal to Boolean constructor in JS?

Tags:

javascript

I start learning javascript, and found some interesting thing

I just can't find any difference between !! and Boolean, but the speed performance seems to be much better with !!

like image 770
Alex Myth Avatar asked Nov 04 '25 02:11

Alex Myth


1 Answers

!! and Boolean(...) are functionally equal. But you should probably use the Boolean constructor in most situations because it is easier to understand by most people, even by beginners.

like image 150
Ben Wainwright Avatar answered Nov 06 '25 19:11

Ben Wainwright



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!