What is the result of following code?

var a = 2;
console.log(~a);
Explanation
Operator ~ is equal to -(n+1), that is means -(2+1) = -3

@xalexvp02 thanks! updated

2018 Feb 4, 5:38:00 PM

Operator ~ is equal to -(n+1), that is means -(2+1) = -3 // -3

2018 Jan 21, 9:52:23 PM

Thanks, @iamdimita ) Fixed

2016 Jun 15, 5:31:15 PM

"is equal", not "are equal"

2016 May 5, 3:15:16 AM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback