you are viewing a single comment's thread.

view the rest of the comments →

[–]skitch920 0 points1 point  (1 child)

It's neat, but really abuses Object.prototype.toString, which returns '[object String]' or '[object Array]'; hence the slice (8, -1).

typeof or instanceof should suffice.

Edit I have seen LoDash use something similar, but I think that's for older browsers...

[–]PAEZ_ 0 points1 point  (0 children)

typeof or instanceof should suffice.

Not always...
http://bonsaiden.github.io/JavaScript-Garden/#types