js.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. <div>你好</div>
  10. <script>
  11. var oBox = document.getElementsByTagName("div")[0];
  12. // oBox.onclick = function(){
  13. // console.log("hello");
  14. // }
  15. // oBox.innerText = "<span>hello</span>";
  16. // oBox.innerHTML = "<span>hello</span>";
  17. oBox.remove();
  18. // oBox.addEventListener("click",function(){
  19. // console.log("hello");
  20. // });
  21. // var a = 10;
  22. // function foo(){
  23. // var a = 20;
  24. // }
  25. // var b = 10;
  26. // var c = b;
  27. // b = 20;
  28. // console.log(c);
  29. // var arr1 = [1,2,3,4,5];
  30. // var arr2 = arr1;
  31. // arr1[0] = "hello";
  32. // console.log(arr2);
  33. // function foo(){
  34. // console.log("hello");
  35. // }
  36. // foo();
  37. // var foo = function(){
  38. // console.log("hello");
  39. // }
  40. // (function(){
  41. // console.log("hello");
  42. // })();
  43. // console.log("a"+1);
  44. // var obj = {
  45. // name:"hello",
  46. // age:10
  47. // }
  48. // var arr = [1,2,3,4,5];
  49. // var str = "hello";
  50. // delete obj.name;
  51. // console.log(obj);
  52. // console.log(typeof null);
  53. // console.log(typeof str);
  54. // console.log(typeof obj);
  55. // console.log(typeof arr);
  56. // for(var key in obj){
  57. // console.log(obj[key]);
  58. // }
  59. // console.log(Array.prototype);
  60. // var a = 1;
  61. // switch(a){
  62. // case a>1:console.log(1);break;
  63. // case a>2:console.log(2);break;
  64. // default:console.log("default");break;
  65. // }
  66. // var a = false;
  67. // var d = 0;
  68. // var c = d||a;//或运算用作赋值操作,如果第一个值为真,则返回第一个值,否则返回第二个值
  69. // console.log(c);
  70. // var b = a>1?"hello":"world";
  71. // var a = 10;
  72. // console.log(a.toString());
  73. // console.log(a+"");
  74. // var arr = [1,2,3,4,5];
  75. // arr.push(6);
  76. // // arr[5] = 6;
  77. // console.log(arr);
  78. // var obj = {
  79. // name:"hello",
  80. // age:10,
  81. // name1:"world"
  82. // }
  83. // var a = 1;
  84. // console.log(obj['name'+a]);
  85. try {
  86. console.log(abc);
  87. } catch (error) {
  88. console.log(
  89. error
  90. )
  91. }
  92. console.log("hello");
  93. // console.log(aaa);
  94. // console.log("world");
  95. </script>
  96. </body>
  97. </html>