predictype / predicates/objects/objectInstanceRelation / objectInstanceRelation
objectInstanceRelation(
source,oper,target):boolean
Defined in: predicates/objects/objectInstanceRelation.ts:28
Checks instance or prototype relation between two values using the specified operation.
any
The value to check.
The relation operation to perform (e.g. ‘instance_of’, ‘prototype_of’).
any
The target to compare against.
boolean
True if the relation check is valid according to the operator, otherwise false.
If the operation is not recognized.
class User {}
const sourceA = new User();
const targetA = User;
const proto = { kind: 'base' };
const child = Object.create(proto);
objectInstanceRelation(sourceA, 'instance_of', targetA); // true
objectInstanceRelation(proto, 'prototype_of', child); // true
Supported Operators: