Js data type

javascript判断数据类型

Object.prototype.toString.call() 方法

Object.prototype.toString.call( null )
// "[object Null]"

Object.prototype.toString.call( undefined )
// "[object Undefined]"

Object.prototype.toString.call( {} )
// "[object Object]"

Object.prototype.toString.call( function(){} )
// "[object Function]"

Object.prototype.toString.call( [] )
// "[object Array]"

Object.prototype.toString.call( 1 )
// "[object Number]"

Object.prototype.toString.call( true )
// "[object Boolean]"

Object.prototype.toString.call( "1" )
// "[object String]"
posted @ 2021-05-31 11:16  源大大123  阅读(133)  评论(0)    收藏  举报