DEV Community

Owen Gallagher
Owen Gallagher

Posted on • Updated on

JavaScript type detection

This is one of those annoying things I have to relearn every time I come back to writing something in JS.

$ [] instanceof Array
true

$ '' instanceof String
false

$ typeof []
'object'

$ typeof ''
'string'

$ typeof new String('')
'object'

$ wow right of course
Enter fullscreen mode Exit fullscreen mode

That, and this.

Top comments (0)