javascript的typeof返回的数据类型
程序员文章站
2022-06-04 21:39:33
...
javascript的typeof返回的数据类型有:
- undefined
- string
- boolean
- number
- Object
- Function
示例:
//underfined
var a;
console.log(typeof a);
//string
var a = "";
var b = "hello"
console.log(typeof a);
console.log(typeof b);
//boolean
var a = true;
console.log(typeof a);
//number
var a = 15;
console.log(typeof a);
//object
var a = null;
var b = {};
var c = [];
console.log(typeof a);
console.log(typeof b);
console.log(typeof c);
//function
function fun1() {};
var fun2 = function () {};
console.log(typeof fun1);
console.log(typeof fun2);
下一篇: 懒人经济盛行,社区电商趁势而起!