Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 12x 12x | /**
* Checks if a `value` is an object.
*
* "object" in terms of this function means a regular object with `string` or
* {@link Symbol} properties.
*
* @remarks
* This function does not behave the same as JavaScript's `typeof` operator,
* which returns `"object"` also for {@link Array}s and `null`.
*
* @example
* ```
* const result = isObject({});
* console.log(result); // true
* ```
*
* @example
* ```
* const result = isObject([]);
* console.log(result); // false
* ```
*
* @param value - the value to check
* @returns `true` if `value` is an object, otherwise `false`
*/
export const isObject = <T extends { [key: string | symbol]: unknown }>(
value: unknown
): value is T => {
return !!value && typeof value === "object" && !Array.isArray(value);
};
|