why '+' act like a parse and what is the difference ??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why '+' act like a parse and what is the difference ???

+"10.1" + +"32.3" vs parseFloat("10.1") + parseFloat("32.3") both statement will produce the same result 42.4 using this statement: +"10.1" + +"32.3" why '+' act like a parse and what is the difference ???

16th Apr 2017, 2:56 PM
Rydel Siono
Rydel Siono - avatar
3 Answers
+ 3
"+" is used for concatenation, i.e bringing two or more strings or vars together.. While "parse" is used to convert something to a particular datatype... E.g parseFloat("10.1") You've just converted 10.1 to a float datatype..
16th Apr 2017, 7:30 PM
Oluseye Richard
Oluseye Richard - avatar
+ 1
I think you getting it mixed up, let's have your code example
17th Apr 2017, 9:32 PM
Soneye Abimbola Oluwasina
Soneye Abimbola Oluwasina - avatar
0
ill tried using this statement: +"10.1" + +"32.3" result would be 42.4 why '+' act like a parse and what is the difference???
16th Apr 2017, 7:44 PM
Rydel Siono
Rydel Siono - avatar