JS數據類型檢測typeof、instanceof、constructor、Object.prototype.toString.call(val)的區別

數據類型檢測的四種方式 typeof 不能細分對象類型的值,都是返回「object」,函數檢測返回「function」。 typeof 10:number typeof new Number(10):object typeof true:boolean typeof new Boolean(true):object typeof 「aaa」:string typeof new String(「aa
相關文章
相關標籤/搜索