Function isInstance

Checks if value passed is a user class instance, created with new MyClass(), as opposed to Plain/POJSO Objects, i.e an object created as literal {} or by Object.create() or new Object().

Also, all builtins (like new Error() / new Number(1) etc) and those created by native code, even with new Xxx(), are not considered as an isInstance() value (it returns false).

To the contrary, new function PseudoClass(){} is a valid instance, as it's a user-defined pseudo class in JS.

  • Parameters

    • value: unknown

      any value

    Returns value is any

    true if the value is an instance object, i.e created as new Thing() where class Thing {}