function myTypeof(val){ var type = typeof(val); var myString = Object.prototype.toString; var res = { '[object Object]' : 'object', '[object Array]' : 'array', '[object Number]' : 'object number', '[object String]' : 'object string', '[object Boolean]' : 'object boolean', }; if(val === null){ return 'null' }else if(type == 'object'){ var tt = myString.call(val); return res[tt] }else{ return type } } console.log(myTypeof(new Number))