In the past, I often used "+" to coerce a character string to numeric form. I recently got tripped up by the fact that "+" is overloaded on concatenation in JavaScript, so instead of 1 + 2 = 3, I got 1 + 2 = 12! I think I'll switch to subtracting zero, as it is just as fast, and unambiguous too boot!
Good article!
In the past, I often used "+" to coerce a character string to numeric form. I recently got tripped up by the fact that "+" is overloaded on concatenation in JavaScript, so instead of 1 + 2 = 3, I got 1 + 2 = 12! I think I'll switch to subtracting zero, as it is just as fast, and unambiguous too boot!