2021年1月5日

摘要: 观察者模式 /* 经典观察者模式 * Observer、Subject * 也可以增加1级抽象,不过JS继承太麻烦,此处从简 * 手动维护List */ // Subject function Subject(name) { this.name = name; this.list = []; } / 阅读全文
posted @ 2021-01-05 17:29 chenyi4 阅读(93) 评论(0) 推荐(0) 编辑

2020年9月24日

摘要: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script> function myFunction(){ document.getElementById("demo").innerHTML="Hello 阅读全文
posted @ 2020-09-24 16:22 chenyi4 阅读(906) 评论(1) 推荐(0) 编辑

2020年9月23日

摘要: 1.全局变量 全局变量 2段测试代码 <script> var a = (new Array(1000000).fill("*aaaa1111")); </script> <script> function name() { var a = (new Array(1000000).fill("*aa 阅读全文
posted @ 2020-09-23 16:24 chenyi4 阅读(706) 评论(0) 推荐(0) 编辑
摘要: 盗一个图 每次点击一次,就会有一条蓝色的柱子,分配一定的内存出来。框出这一条,查看分配的内存值为78.3kb;constructor里面保存了分配给了哪些 变量和值,其中array 占 3%,可以看到数组中包含的变量,arr; 通过sampling可以看出哪些函数在申请使用内存,浏览器分配内存是由哪 阅读全文
posted @ 2020-09-23 14:46 chenyi4 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 会导致页面卡顿,页面崩溃 5,6 秒以后,就能体会到内存泄漏的结果 <style> #top{ width: 100px; height: 100px; background: red; }</style> <body> <div id="top"></div> </body> <script> v 阅读全文
posted @ 2020-09-23 14:33 chenyi4 阅读(661) 评论(0) 推荐(0) 编辑
摘要: 参考 : https://www.jianshu.com/p/12d5209ef882 <style> #button{ width: 100px; height: 100px; background: red; cursor: pointer; } </style> <body> <div id= 阅读全文
posted @ 2020-09-23 11:17 chenyi4 阅读(127) 评论(0) 推荐(0) 编辑

2020年9月3日

摘要: 1.限制调速 点进去设置自己需要的速度,恒定速度加载 2.刷新页面,可以看到Finish 速度是2.63 s 每个文件加载速度为 Time 的时间为每个文件加载所消耗的时间 2.查看并发加载 这段重叠的部分是并发执行的,也是就是说,多加载a.js 和 b.js 是不会影响速度的,所以删除这个文件测一 阅读全文
posted @ 2020-09-03 17:57 chenyi4 阅读(349) 评论(0) 推荐(0) 编辑

2020年8月10日

摘要: 1.jquery $('.a').find('.b') , $('.a') 以后返回一个对象, find('.b') 以后 也是返回一个对象,对$('.a')装饰一个方法 find , $('.a').find('.b') 再加一个装饰 width(); 返回的仍然是一个完整的jquery的对象 这 阅读全文
posted @ 2020-08-10 17:37 chenyi4 阅读(133) 评论(0) 推荐(0) 编辑

2020年7月30日

摘要: 1.数据是数组类型的时候 原数据: this.testArr = [{c: 12}, {}]; 操作: this.testArr[0] = { a: 123 }/或者 this.testArr[0].c = 12222;操作完了以后不更新 执行操作 this.testArr = this.testA 阅读全文
posted @ 2020-07-30 11:11 chenyi4 阅读(686) 评论(0) 推荐(0) 编辑

2020年6月29日

摘要: 闭包就是函数作用域是一个封闭的区域,作用域变量携带到外层,可以携带它对父作用域的变量的引用,不会被销毁 最近在看 《JavaScript编程精粹》这本书,里面提到高级程序都会使用到闭包 应用场景 1.setTimeout的循环 for(var i = 1; i < 5; i++){ setTimeo 阅读全文
posted @ 2020-06-29 11:43 chenyi4 阅读(113) 评论(0) 推荐(0) 编辑

导航