MCPcopy Create free account
hub / github.com/circircir-circle/human_exist_device / isPlainObject

Method isPlainObject

mini_program/common/Tools.js:406–423  ·  view source on GitHub ↗

* 判断传入的参数是否为纯粹的对象,即直接量{}或new Object()创建的对象 * @param {[type]} obj [description] * @return {Boolean} [description]

(obj)

Source from the content-addressed store, hash-verified

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 * 判断对象是否为空

Callers 1

extendMethod · 0.95

Calls 1

typeMethod · 0.95

Tested by

no test coverage detected