# Beginners question on numeric conversion

#### OBXKH

Code:
``````let str = "123"; alert(typeof str); //
string let num = Number(str); //
becomes a number 123 alert(typeof num); // number``````

kindly explain

Code:
``let num = Number(str); // becomes a number 123``

i dont follow

thanks!!

Double or single quotes make the expression between them a string, Number() turns /* in case it consists of digits, but is a string */ the expression between it's braces into a number. Nothing but a simple magic <wink>

#### OBXKH

thanks!

The unary plus or, in other words, the plus operator + applied to a single value, doesn’t do anything to numbers. But if the operand is not a number, the unary plus converts it into a number.

For example:

Code:
``````// No effect on numbers
let x = 1;

let y = -2;

// Converts non-numbers

#### MeMate

+ isn't convert anything to a number at all.

Code:
``````var a = "1";
var b=2;
var c= a + b;

//BUT

var c=parseFloat(a)+b;

+ isn't convert anything to a number at all.

Code:
``````var a = "1";
var b=2;
var c= a + b;

//BUT

var c=parseFloat(a)+b;

if you put + to the proper place some strings will suddenly turn to numbers:

JavaScript:
``````const a = "1";
const b = 2;
const c = + a + b;