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
150Awesome.
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
150Awesome.