14.数据类型判断.html 813 B

123456789101112131415161718192021222324252627282930313233
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. var a = '123';
  11. console.log(typeof null);
  12. if(null===undefined) {
  13. console.log(1)
  14. }else {
  15. console.log(2)
  16. }
  17. // 0.1+0.2!=0.3
  18. /**
  19. * 1.typeof 类型判断
  20. * 2.instanceof
  21. * 3.Object.prototype.toString.call()
  22. * 4.constructor
  23. */
  24. var fn1 = function() {
  25. console.log("这是一个函数");
  26. }
  27. console.log(fn1 instanceof Function);
  28. console.log(Object.prototype.toString.call(true));
  29. var num = 10;
  30. console.log(num.constructor);
  31. </script>
  32. </body>
  33. </html>