function isType(type) { return function (content) { let t = Object.prototype.toString.call(content).replace(/[objects|]/g, '') return t === type; } } let arr = ['String', "Array", "Object", 'Function', "Number", 'Null']; let util = {}; arr.forEach(item => { util['is' + item] = isType(item); }) console.log(util.isNumber(111));