JavaScript判断变量类型

使用JavaScript变量时是无法判断出一个变量是0 还是“”的

这时可用typeof()来判断变量是string 还是number来区分0和“”,

   typeof(undefined) == 'undefined'
 typeof(null) == 'object'
 typeof("") == 'string'
 typeof(0) == 'number'
 typeof(false) == 'boolean'

原文地址:https://www.cnblogs.com/xbblogs/p/5329914.html