9 lines
286 B
JavaScript
9 lines
286 B
JavaScript
const checkTypes = {};
|
|
['Array', 'Object', 'String', 'Number', 'Boolean', 'Null', 'Undefined', 'RegExp', 'Function'].forEach(type => {
|
|
checkTypes[`is${type}`] = function (data) {
|
|
return Object.prototype.toString.call(data) === `[object ${type}]`
|
|
}
|
|
})
|
|
|
|
export default checkTypes
|