标签:prototype typeof str val ber eof lse color return
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))
标签:prototype typeof str val ber eof lse color return
原文地址:https://www.cnblogs.com/xm16/p/10357743.html