jskatas.org Continuously Learn JavaScript. Your Way.

Unary Operators: Unary "+" operator

converts its operand to the Number type

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

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


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.