function judgeTypeFnCreator (type) {
const toString = Object.prototype.toString
return function isType (o) {
return toString.call(o) === `[object ${type}]`
}
}
 
 
const isFunc = judgeTypeFnCreator('Function')
const isUndef = judgeTypeFnCreator('Undefined')
const isArray = judgeTypeFnCreator('Array')
const isString = judgeTypeFnCreator('String')
const isObject = judgeTypeFnCreator('Object')
const isNumber = judgeTypeFnCreator('Number')
 
 
function deepAssign(to, from) {
for (let key in from) {
if (!to[key] || typeof to[key] !== 'object') {
to[key] = from[key]
} else {
deepAssign(to[key], from[key])
}
}
}

相关文章:

  • 2021-07-09
  • 2021-06-28
  • 2021-07-08
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
猜你喜欢
  • 2021-06-10
  • 2021-07-24
  • 2022-12-23
  • 2021-06-06
  • 2021-11-22
  • 2022-12-23
  • 2021-04-05
相关资源
相似解决方案