第一种方法typeof

typeof是一种运算符,它的值有以下几种

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ces</title>
</head>
<body>
    <script>
    console.log(typeof "Liesbeth");//"string"
    console.log(typeof 12);//"number"
    console.log(typeof true); //"boolean"
    console.log(typeof undefined);//"undefined"
    console.log(typeof null);//"object"
    console.log(typeof {name:"Liesbeth"});//"object"
    console.log(typeof function(){});//"function"
    console.log(typeof []);//"object"
    console.log(typeof new Date);//"object"
    console.log(typeof /[0-9]/);//'object'
    console.log(typeof new Number(123));//'object'
    function Person(){};
    console.log(typeof new Person);//'object'

    </script>

</body>
</html>
typeof

相关文章:

  • 2021-12-29
  • 2021-10-18
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2021-06-22
  • 2022-12-23
  • 2021-11-28
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
相关资源
相似解决方案