1.正则.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. <!-- 正则表达式
  10. const 名称 = /需要校验的规则/
  11. 修饰符:
  12. g 匹配全局
  13. i 不区分大小写
  14. -->
  15. <script>
  16. const reg = /aa/gi;
  17. const str = 'AA,四大名著有aa,我也爱看Aa'
  18. console.log(reg.test('xxxxxx'));
  19. console.log(reg.exec(str));
  20. console.log(str.match(reg))
  21. const res = str.replace(reg, '红楼梦');
  22. console.log(res);
  23. /**
  24. * js数据类型
  25. * 基本:string boolean number undefined null symbol bigInt
  26. * 引用:Object(对象 数组 函数)
  27. * 怎么去判断数据类型
  28. * typeof
  29. * instanceof
  30. * Object.prototype.toString.call()
  31. * constructor
  32. * 盒模型
  33. * 数组的方法 那些会改变原数组 那些不会改变原数组
  34. * for in / for of
  35. * map/forEach
  36. * 为什么data是函数
  37. *
  38. * this指向
  39. * call bind apply
  40. * Promise
  41. * async await
  42. * eventLoop
  43. */
  44. let arr = [1, 2, 3, 4, 5];
  45. let obj = {
  46. aa: 11,
  47. bb: 22
  48. }
  49. let m = obj;
  50. m.aa = 33;
  51. console.log(m, 'm')
  52. console.log(obj, 'obj')
  53. // for (let key of Object.entries(obj)) {
  54. // console.log(key, 'key');
  55. // }
  56. // arr.forEach(item => {
  57. // console.log(item)
  58. // return c = item + 1
  59. // });
  60. // console.log(arr)
  61. </script>
  62. </body>
  63. </html>