3.js类型.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=xw, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. /**
  11. * js基本数据类型
  12. * string number boolean undefined null
  13. *
  14. * 引用数据类型 Object
  15. * object array function
  16. *
  17. *
  18. * typeof判断数据类型
  19. * null 会判断为object
  20. */
  21. console.log(typeof(1));
  22. console.log(typeof("1"));
  23. console.log(typeof(false));
  24. console.log(typeof(undefined));
  25. console.log(typeof(null));
  26. var a = {
  27. a:"你好"
  28. };
  29. var b = [1,2,34];
  30. var c = function() {
  31. console.log("你好")
  32. };
  33. console.log(typeof(a));
  34. console.log(typeof(b));
  35. console.log(typeof(c));
  36. if(null == undefined) {
  37. console.log("你好")
  38. } else {
  39. console.log("大家好")
  40. }
  41. /**
  42. * = 赋值
  43. * == 相等 强制转换类型
  44. * === 全相等 类型和值必须全部相等
  45. */
  46. </script>
  47. </body>
  48. </html>