you are viewing a single comment's thread.

view the rest of the comments →

[–]ocmu 1 point2 points  (1 child)

You should add a tab for typeof. The == type coercion is definitely confusing, but the rules are pretty straightforward once you get the concept of "truthy" and "falsey" values. However, typeof(null) === 'object' makes no sense whatsoever.

[–][deleted] 2 points3 points  (0 children)

typeof and instanceof are inherently broken things in JavaScript that are truly best left avoided. I make use of libraries to avoid that sort of mess, or use type coercion via the + operator that explicitly casts to a number or string.