提交学习笔记专用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
424 B

  1. import { getType } from './getType.js';
  2. /**
  3. * Returns whether the payload is a plain JavaScript object (excluding special classes or objects
  4. * with other prototypes)
  5. */
  6. export function isPlainObject(payload) {
  7. if (getType(payload) !== 'Object')
  8. return false;
  9. const prototype = Object.getPrototypeOf(payload);
  10. return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
  11. }