前端面试题——13.javascript的typeof返回哪些数据类型?

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_40686529/article/details/102556000

返回八种数据类型:

  • number typeof (1)
  • function typeof (function(){})
  • string typeof ("aaa")
  • undefined typeof(a) // 没有定义的变量
  • boolean typeof true // 或者false
  • bigint 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>

猜你喜欢

转载自blog.csdn.net/qq_40686529/article/details/102556000