@thi.ng/checks
Version:
Collection of 70+ type, feature & value checks
14 lines (13 loc) • 323 B
JavaScript
const OBJP = Object.getPrototypeOf;
/**
* Similar to {@link isObject}, but also checks if prototype is that of
* `Object` (or `null`).
*
* @param x -
*/
export const isPlainObject = (x) => {
let p;
return (x != null &&
typeof x === "object" &&
((p = OBJP(x)) === null || OBJP(p) === null));
};