Unary Plus and Minus Operator Sub-Group
The Unary Plus Operator ( + )
The Unary Minus 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 plus and minus operator sub-group. Some special situation cases are explained. And finally, some scripting examples are provided with comments.





The Basics of Unary Plus and Minus Operators





Some Script Examples


Expression y = Comment
var x = 4;
y = +x;
4 unary plus
the unary plus has no effect on a number (no op)
var x = "abc";
y = +x;
NaN unary plus
the unary plus returns NaN for non-numeric operands;
in this case, the operand could not be converted to a number
var x = "5";
y = +x;
5 unary plus
the unary plus returns 5;
in this case, the operand could be converted to a number
var x = 4;
y = -x;
-4 unary minus
the unary minus returns the negation of the operands value
var x = -4;
y = -x;
4 unary minus
the unary minus returns the negation of the operands value


Top            

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