DEV Community

Discussion on: 20 JavaScript One-Liners That Will Help You Code Like a Pro

Collapse
 
matthewadams profile image
Matthew Adams

Just use typeof

Collapse
 
andreykalechev profile image
Leechy

nope:

typeof []
// "object"
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
matthewadams profile image
Matthew Adams

An array is an object. Whether it's an Array is a separate question. I suppose if trueTypeOf were documented, describing its semantics, it would be clearer. Remember, all, syntax doesn't convey everything. You also need semantics. :)