* 判断传入的参数是否为纯粹的对象,即直接量{}或new Object()创建的对象 * @param {[type]} obj [description] * @return {Boolean} [description]
(obj)
| 404 | * @return {Boolean} [description] |
| 405 | */ |
| 406 | isPlainObject(obj) { |
| 407 | let getProto = Object.getPrototypeOf |
| 408 | let class2type = {} |
| 409 | let toString = class2type.toString |
| 410 | let hasOwn = class2type.hasOwnProperty |
| 411 | let fnToString = hasOwn.toString |
| 412 | let ObjectFunctionString = fnToString.call(Object) |
| 413 | let proto, Ctor |
| 414 | if (!obj || this.type(obj) !== '[object Object]') { |
| 415 | return !1 |
| 416 | } |
| 417 | proto = getProto(obj) |
| 418 | if (!proto) { |
| 419 | return !0 |
| 420 | } |
| 421 | Ctor = hasOwn.call(proto, 'constructor') && proto.constructor |
| 422 | return typeof Ctor === 'function' && fnToString.call(Ctor) === ObjectFunctionString |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * 判断对象是否为空 |