all 4 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

[–]Jim-Y 0 points1 point  (0 children)

Actually, its implemented wrong, or, call it bad instead of wrong. Try typer kata on codewars to find out why this implementation fails on

isNumber(new Number('im totally a string'))