Unary NOT Operator Sub-Group
The Bitwise NOT Operator ( ~ )
The Logical NOT Operator ( ! )



Navigation Aids -- This Page     Navigation Aids -- This Topic     Navigation Aids -- This Site








Review of Terms Related to This Topic





The Purpose for this Page

This page will show the basic rules for the JavaScript unary NOT operator sub-group. Some special situation cases are explained. And finally, some scripting examples are provided with comments.





The Basics of Unary NOT Operator Sub-group





Some Script Examples


Expression y = Comment
var x = 4;
y = ~x;
-5 unary bitwise NOT
the unary bitwise NOT returns the one's complement
var x = -4;
y = ~x;
3 unary bitwise NOT
the one's complement of -4 is 3
var x = true;
y = !x;
false unary logical NOT
returns boolean complement
var x = false;
y = !x;
true unary logical NOT
returns boolean complement
var x = 0;
y = !x;
true unary logical NOT
a zero will return true
var x = 4;
y = !x;
false unary logical NOT
a number other than zero will return false
var x = true;
y = !!x;
true unary logical NOT
tricky: a double NOT reverses the reversal
var x = 0;
y = !!x;
false unary logical NOT
too tricky: a double NOT converts the zero to true, then reverses the true to false
var x = false;
y = !!!!!x;
true unary logical NOT NOT NOT NOT NOT
go figure


Top            

Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson