predictype / predicates/objects/objectAttributes / objectAttributes
objectAttributes(
source
,oper
,key
):boolean
Defined in: predicates/objects/objectAttributes.ts:32
Checks object property attributes (writable, enumerable, configurable, accessor, data property) using the specified operation.
object
The object to check.
The attribute operation to perform (e.g. ‘is_writable’, ‘is_accessor’).
The property key to check.
string |
symbol |
boolean
True if the attribute check is valid according to the operator, otherwise false.
If the operation is not recognized.
const obj = { foo: 42 };
const obj2 = {};
const sym = Symbol('bar');
Object.defineProperty(obj2, sym, { value: 1, writable: false });
objectAttributes(obj, 'is_writable', 'foo'); // true
objectAttributes(obj2, 'is_writable', sym); // false
Supported Operators: