1.正则.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. let arr = [1, 2, 3, 4, 5];
  39. let obj = {
  40. aa: 11,
  41. bb: 22
  42. }
  43. let m = obj;
  44. m.aa = 33;
  45. console.log(m, 'm')
  46. console.log(obj, 'obj')
  47. // for (let key of Object.entries(obj)) {
  48. // console.log(key, 'key');
  49. // }
  50. // arr.forEach(item => {
  51. // console.log(item)
  52. // return c = item + 1
  53. // });
  54. // console.log(arr)
  55. </script>
  56. </body>
  57. </html>