JS: typeof, instanceof, .constructor
typeof operator return the type of the object, but array, object, date, regex, etc all just return "object".
instanceof operator checks if a object is in the Prototype Chain of a function's property "prototype"'s value.
Property key "constructor" is meant to return the function that created the object.
🟢 tip: You shoud avoid using any of them, because they are not reliable.
Instead, check directly what you are looking for, by:
- Check what is the parent object.
- Check for properties you are looking for.
- Check for the exact “subtype” of a object.