Skip to main content

getType

获取数据类型

examples

source code

getType(1) //string

getType(2) //number

getType(true) //boolean

getType([object Set]) //set

getType([object Map]) //map

getType(Wed Dec 25 2024 02:36:34 GMT+0000 (Coordinated Universal Time)) //date

getType([object Object]) //object

getType(function anonymous( ) { }) //function

getType(undefined) //undefined

getType(null) //null

const getType = (value) => {
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
};