Stack Exchange
Stack Overflow
Questions
Tags
Users
About
Stack Overflow
Public
Questions
Tags
Users
About
how string() works here? addition of strings and numbers in string();
Asked
Jan 21 '22 at 03:00
Active
Jan 21 '22 at 03:13
Viewed
15 times
0
enter image description here
String("12"+3) // output : 123
String(+"12"+3) // output : 15
javascript
edited
Jan 21 '22 at 03:12
Aldrin Bright
asked Jan 21 '22 at 03:00
Aldrin Bright
23
5
has nothing to do with String()
–
epascarello
Jan 21 '22 at 03:11
https://stackoverflow.com/questions/6682997/what-is-the-purpose-of-a-plus-symbol-before-a-variable
–
epascarello
Jan 21 '22 at 03:12
1
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unary_plus
–
epascarello
Jan 21 '22 at 03:14
`+'12'` is shorthand for `Number('12')`. [Spec here](https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-unary-plus-operator).
–
tao
Jan 21 '22 at 03:22
0 Answers
0