Unary Operator: A unary operation contain only one operand. Here, ‘+’ unary plus operator converts its operand to Number type. While it also acts as an arithmetic operator with two operands which returns an addition result on calculation.
Example: The variable “_” with string type is stored in variable “r” with “number” type.
var _ = "1"; var r = +_;
typeof(r) will be number
Example 1: Conversion of String to Number
Example 2: Performing arithmetic addition operation by converting them to number type.
- What does the “+” (plus sign) CSS selector mean?
- What does '<?=' short open tag mean in PHP ?
- What does it mean to start a PHP function with an ampersand?
- What is the difference between MEAN.js and MEAN.io?
- Ternary operator vs Null coalescing operator in PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.