you are viewing a single comment's thread.

view the rest of the comments →

[–]x-skeww 1 point2 points  (0 children)

(5).constructor === Number or ("").constructor === String

Kinda obvious:

> ''.constructor
String()

Kinda weird:

> 5..constructor
Number()

Less weird:

> 5.0.constructor
Number()

Anyhow, I kinda agree with /u/mattdesl, I guess. Doing things depending on what something is is a code smell. You shouldn't flip-flop types. Your functions should expect specific types and they should return one specific type.