javascript - plus signs in the JS code - why aren't they optional here -
i'm curious answer taken dagg nabbit @ so here: convert hh:mm:ss string seconds in javascript var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]); right, var seconds = (a[0]) * 60 * 60 + (a[1]) * 60 + (a[2]); doesnt work expected - doesn't calculate number of seconds. why? they cause implicit conversion of string number. in browser's debug console, try: > typeof +'1' "number" > typeof '1' "string"