DEV Community

Owen Gallagher
Owen Gallagher

Posted on • Edited on

3 2

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)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more