typeof 可以用来检测给定变量的数据类型,可能的返回值:
- ‘undefined’
- ‘boolean’
- ‘string’
- ‘number’
- ‘object’
- ‘function’
var hahaha = 'hello world'; alert(typeof hahaha); // 'string' alert(typeof hahaha); // 'number'
typeof 可以用来检测给定变量的数据类型,可能的返回值:
var hahaha = 'hello world'; alert(typeof hahaha); // 'string' alert(typeof hahaha); // 'number'
转载于:https://www.cnblogs.com/LeesinDong/p/10835600.html