The unary "+" operator
is the "+" that preceeds an operand
converts its operand to the Number type
WHEN converting a numeric string THEN it returns its value as a number
even WHEN converting the string "-Infinity" THEN it returns the Number Infinity
WHEN converting null
THEN it returns +0
WHEN converting true
THEN it returns 1
WHEN converting an object with a method valueOf
THEN its value is returned
Links
The original ECMAScript 1 specification, "Unary + Operator" is on page 40, chapter 11.4.6 (in a 110 pages PDF).
The original ES1 spec describes the `Number` type in chapter 8.5 (a 110 pages PDF).
The MDN page.
Tweeting that not-assertions make sense, sometimes.
Required Knowledge
- All unary operators (Unary Operators)
Related Katas
Unary Operators
- All unary operators
- Unary "+" operator
- Unary "+" operator in depth
Bitwise Shift Operators
Rest operator
Spread operator
Difficulty Level
INTERMEDIATE
First Published
7 February 2021
Stats
7 tests to solve