const isType = type => target => `[object ${type}]` === Object.prototype.toString.call(target)
const isArray = isType('Array')
const isObject = isType('Object')
console.log(isArray(['1', '2']))
console.log(isObject({}))
function typeVerification (target) {
const ret = typeof target
console.log(ret)
const template = {
'[object Number]' : 'number - object',
'[object String]' : 'string - object',
'[object Boolean]': 'boolean - object',
'[object Object]' : 'object',
'[object Array]' : 'array'
}
if (target === null) {
return null
}
if (ret === 'object') {
const str = Object.prototype.toString.call(target)
return template[str]
}
return ret
}
console.log(typeVerification(null))
console