Simplify string/typecast by eliminating else-ifs

According to http://rmurphey.com/blog/2012/12/10/js-conditionals/ there is no
`else if` in JavaScript anyway. Also make it bail out faster when parameter is
already not a string.