0

Why this happpen? Is it a rule in JS?

let a = "+6"; alert(a); // +6 alert(+a); // 6 https://code.sololearn.com/WD2YN22TzBcT/?ref=app

19th Jul 2019, 8:32 AM
Merida
Merida - avatar
1 Respuesta
+ 3
As a string, a is just a text "+6", so that's why it shows the plus sign. +a is a number, and numbers don't show the plus sign, so there will be no plus sign
19th Jul 2019, 8:35 AM
Airree
Airree - avatar