直接上代码: <script> var browser = (function () { var isIE6 = /msie 6/i.test(navigator.userAgent); var isIE7 = /msie 7/i.test(navigator.userAgent); var isIE8 = /msie 8/i.test(navigator.userAgent); var isIE9 = /msie 9/i.test(navigator.userAgent); var isIE
对于确定JS内置对象类型,JS提供了typeof运算符,该运算符得到的结果为以下6种:number,boolean,string,function,object,undefined.不过对绝大多数对象而言,typeof都返回"object",无法确定具体的类型.我们使用一种函数Object.prototype.toString.call来判断 <script> var a = 1; console.log("a:"+typeof a); //number