From a82aeeaa5e06cf7cccc5e2d5da468c26c8e57797 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 31 Oct 2021 12:34:45 +0700 Subject: [PATCH] Add FAQ about `instanceof` --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index c9b5463..f956fcc 100644 --- a/readme.md +++ b/readme.md @@ -602,6 +602,10 @@ For the ones I found, pick 3 of these. The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive. +### Why not just use `instanceof` instead of this package? + +`instanceof` does not work correctly for all types and it does not work across [realms](https://stackoverflow.com/a/49832343/64949). Examples of realms are iframes, windows, web workers, and the `vm` module in Node.js. + ## For enterprise Available as part of the Tidelift Subscription.