04 2020 档案
数组去重,可带参数
摘要:const aa = [ {name:'aaa',age:1}, { name: 'bbb', age: 2 }, { name: 'cccc', age: 3 }, { name: 'aaa', age: 1 }, { name: 'bbb', age: 5 }, { name: 'aaa', a 阅读全文
posted @ 2020-04-13 15:32 chenlw101 阅读(196) 评论(0) 推荐(0)
深度比较
摘要:let obj1 = { a:111, b:"hahah", c:{ name:"qaz", age:45 }, d:[1,2,3,4] } let obj2 = { a: 111, b: "hahah", c: { name: "qaz", age: 45 }, d: [1, 2, 3, 5] } 阅读全文
posted @ 2020-04-13 10:15 chenlw101 阅读(167) 评论(0) 推荐(0)
保留空格换行样式
摘要:<pre> 元素可定义预格式化的文本。被包围在 pre 元素中的文本通常会保留空格和换行符。而文本也会呈现为等宽字体。 <pre>的内容自动换行的问题(兼容多个浏览器): pre { white-space: pre-wrap; white-space: -moz-pre-wrap; white-s 阅读全文
posted @ 2020-04-13 09:37 chenlw101 阅读(235) 评论(0) 推荐(0)
web安全
摘要:xss攻击预防 npm i xss 前端在显示的时候替换<> 1.替换特殊字符,如 < 变成&lt; > 变成&gt; 2.<script>变成&lt;script&gt;,直接显示,而不会作为脚本执行 XSRF攻击预防 1.使用post接口 2.增加验证 阅读全文
posted @ 2020-04-11 16:04 chenlw101 阅读(117) 评论(0) 推荐(0)
性能优化
摘要:原则: 1、多使用内存、缓存或者其他方法 2、减少CPU计算量,减少网络加载耗时 (防抖,节流,图片懒加载) //防抖(input输入返回值)input.addEventListener('keyup', debounce(()=>{ console.log(input.value) }),600) 阅读全文
posted @ 2020-04-11 15:48 chenlw101 阅读(143) 评论(0) 推荐(0)
页面加载的过程(简-前端)
摘要:1.DNS解析:域名->IP地址 2.浏览器根据IP地址向服务器发起http请求 3.服务器处理http请求,并返回给浏览器 渲染过程 1.根据html代码生成DOM Tree 2.根据css代码生成CSSOM 3.将DOM Tree和CSSOM整合行程Render Tree 4.根据Render 阅读全文
posted @ 2020-04-11 14:14 chenlw101 阅读(1234) 评论(0) 推荐(0)