predictype / predicates/objects / objectProperty
objectProperty(
source,oper,key):boolean
Defined in: predicates/objects/objectProperty.ts:28
Checks if an object has or lacks a property (own or inherited) using the specified operation.
object
The object to check.
The property operation to perform (e.g. ‘contains_property’, ‘lacks_own_property’).
string | symbol
The property key to check.
boolean
True if the property check is valid according to the operator, otherwise false.
If the operation is not recognized.
const source = Object.create({ inherited: true });
source.own = 42;
objectProperty(source, 'contains_property', 'inherited'); // true
objectProperty(source, 'contains_own_property', 'own'); // true
objectProperty(source, 'lacks_own_property', 'inherited'); // true
Supported Operators: