isInstanceOf

function isInstanceOf<T>(klass): (x) => x is T

Since instanceof should generally be avoided, this function should generally be avoided as well.

A valid use case is for native types, like Uint8Array.

Type parameters

Type parameter
T

Parameters

ParameterType
klassAbstractConstructor<T>

Returns

Function

Parameters

ParameterType
xunknown

Returns

x is T