string conversion in javascript

February 27, 2014

Almost every day, javascript blows my mind. Today I discovered that you can convert a string to a number simply by prepending a +:

> typeof(+"this is a string")
"number"
> typeof(+"100")
"number"
> +"100" + 50
150

Awesome.


Mostly Katie explaining things to herself.

© 2022