What will be the result of the following code?
console.log(~true);
Explanation
JavaScript uses 32-bit signed numbers. Bitwise NOT Operator (~) was used:
var a = true;
~a = - (a + 1)
~true == ~1 // true is always 1
Read more: Bitwise NOT Operator (~)

@224930110692 @mrameshkumarc21 it is tilde (~) operator, not minus

2017 Dec 5, 3:40:27 PM

-true = -1

2017 Nov 27, 12:44:38 PM

result of this question is wrong;

2017 Nov 27, 12:44:25 PM

i didn't understand this description

2017 Oct 11, 4:00:11 AM

Didn't notice it is tilde, thought it was minus :/

2015 Jun 26, 10:35:28 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback