前言
一些基礎的但是往往又容易忽略的
一、JS中有哪些基本資料型別?(五"原"一"引")
原始型別:Undefined、Null、Boolean、Number、String
參考型:Object
二、typeof & instanceof
1.typeof
(1)、typeof()回傳值是一個資料型別

(2)、檢測正常參考型

(3)、少 null

(4)、多 function

2.instanceof
instanceof回傳的是一個Boolean資料型別(true/false)
(1) 、語法:
A instanceof B
(2)、原型鏈檢測:
A instanceof B //true
B nstanceof C //true
所以: A nstanceof C //true
最后:
小妙招: 檢測某個想要檢測的資料型別
console.log (object.prototype.toString.call( ))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/288327.html
標籤:AI
