Checks whether a value can have properties. Use this when you have an unknown value and you want
to access its properties as unknown. This is a friendly solution for dealing with unknown objects
in TypeScript.
This function is intended to be used on values that will be used as "plain objects", i.e. not
Array, Date, RegExp or other class instances. But it's safe to use on any value.
Parameters
value: unknown
Returns valueisRecord<any,unknown>
true if value is a non-null object that is not an array.
Example
// Before: if (typeofvalue === 'object' && value !== null && 'property'invalue && typeofvalue.property === 'string') { // use value.property } // After: if (isIndexableObject(value) && typeofvalue.property === 'string') { // use value.property }
Checks whether a value can have properties. Use this when you have an unknown value and you want to access its properties as unknown. This is a friendly solution for dealing with unknown objects in TypeScript.
This function is intended to be used on values that will be used as "plain objects", i.e. not Array, Date, RegExp or other class instances. But it's safe to use on any value.