Unary +

// No effect on numbers
let x = 1;
alert( +x ); // 1
let y = -2;
alert( +y ); // -2

*!*
// Converts non-numbers
alert( +true ); // 1
alert( +"" );   // 0
*/!*

The unary plus or, in other words, the plus operator + applied to a single value, doesn't do anything with numbers, but if the operand is not a number, then it is converted into it.

Related concepts

Unary + — Structure map

Clickable & Draggable!

Unary + — Related pages: