返回八种数据类型:
number typeof (1)function typeof (function(){})string typeof ("aaa")undefined typeof(a) // 没有定义的变量boolean typeof true // 或者falsebigint typeof 99999999n // 最新型数据 ,以n结尾的整型数据symbol typeof Symbol() // Symbol()创建不同的值object typeof([1]) // 数组,null,对象代码:
<!DOCTYPE html><html lang="en"><head></head><body><script type="text/javascript">console.log(typeof (1));console.log(typeof (function(){}));console.log(typeof ("aaa"));console.log(typeof(a));console.log(typeof true);console.log(typeof 999999n);console.log(typeof Symbol());console.log(typeof []);</script></body></html>