[].forEach.call(['String','Number','Date','Error','RegExp'],function(name){ this['is' + name] = function(obj){ return toString.call(obj) === '[object '+name+']'; }; });var num = 123456; var a = isNumber(num); console.log(a);