RubyLouvre / jsbook

一些章节
275 stars 84 forks source link

redux4的isPlainObject #214

Open RubyLouvre opened 6 years ago

RubyLouvre commented 6 years ago
function isPlainObject(obj) {
  if (typeof obj !== 'object' || obj === null) return false

  let proto = obj
  while (Object.getPrototypeOf(proto) !== null) {
    proto = Object.getPrototypeOf(proto)
  }

  return Object.getPrototypeOf(obj) === proto
}