possibly an instance of a class
a class constructor (usually starts with big letter!)
isInstance({}, Object) => true
isInstance(Promise.resolve(), Promise) => true
isInstance(/hello/i, RegExp) => true
isInstance('plain str', String) => false
isInstance(new String('str obj'), String) => true
isInstance(22, Number) => false
isInstance(new Number(33), Number) => true
isInstance(2, NaN) => false // Note that `2 instanceof NaN` throws
Checks if a provided value is an instance of the provided class (considers inheritance)
Uses the
instanceofoperator under the hood but does not throw for some cases where JavaScript chokes (e.g.2 instanceof NaNthrows, butisInstance(2, NaN)returnsfalse).