企业网站建设基本流程图,没有文字的网站怎么优化,网站建设搭建公司,好的装修效果图网站常考算法 排序算法#xff1a;快速排序、归并排序、堆排序等。 查找算法#xff1a;二分查找、哈希表查找等。 动态规划#xff1a;解决最优化问题#xff0c;如斐波那契数列、最长公共子序列等。 图论算法#xff1a;最短路径#xff08;Dijkstra、Floyd-Warshall快速排序、归并排序、堆排序等。 查找算法二分查找、哈希表查找等。 动态规划解决最优化问题如斐波那契数列、最长公共子序列等。 图论算法最短路径Dijkstra、Floyd-Warshall、拓扑排序等。 字符串处理KMP算法、正则表达式匹配等。
遍历方法总结 链式调用
数组的很多操作可以构成链式操作类似这样的格式…map().filter(…).sort(…).map(….)链式操作就是对象方法返回类型是自身的。比如map是属于数组的方法它返回数组所以构成了链式操作优势语义清晰、思考方便数据量小的时候很有用(1W)问题性能、空间
递归
递归通常需要初始条件和递归表达式
阶乘n! n x (n-1) !
斐波那契f(1) 1, f(2) 1f(n) f(n-1) f(n-2), n2 拷贝
push/pop/shift/unshift/splice都在原始数据上进行修改
concat/slice/map/reduce都会对原始数据进行浅拷贝 DOM结点的绝对位置
offsetLeft、offsetRight相对于offsetParent的位置 Element.getBoundingClientRect()相对于视窗的位置受滚动的影响 !DOCTYPE html
html langen
headmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0title递归/title
/head
bodyscript// 阶乘function factorial(n) {if (n 1) return 1return n * factorial(n - 1)}// 斐波那契数列 1 1 2 3 5 8 13 21 34 55 89 144function fibonacci(n) {if (n 1 || n 2) return 1return fibonacci(n - 1) fibonacci(n - 2)}// 从底端构造递归function fibonacci1(n) {let [a,b] [1,1]for(let i 3; i n; i) {[a,b] [b, a b]}return b}// console.log(测试 fibonacci1);// console.log(fibonacci1(10));function fibonacci2(n) {return Array(n - 2).fill(0).reduce(([a,b],_) {return [b, a b]}, [1,1])[1]}// console.log(测试 fibonacci2);// console.log(fibonacci2(10));// 递归实现深拷贝function deepClone(obj) {if (typeof obj ! object || obj null) return obj// const newObj Array.isArray(obj) ? [] : {}// const newObj obj instanceof Array ? [] : {}// const newObj obj.constructor Array ? [] : {}// const newObj Object.prototype.toString.call([]) [object Array] ? [] : {}const newObj new obj.constructor()for(let key in obj) {if(obj.hasOwnProperty(key)) {newObj[key] deepClone(obj[key])}}return newObj}// 测试用例 function testDeepClone() { console.log(测试普通对象:); const obj1 { a: 1, b: { c: 2 } }; const clonedObj1 deepClone(obj1); console.assert(obj1 ! clonedObj1, 对象应该是不同的引用); console.assert(obj1.b ! clonedObj1.b, 嵌套对象也应该是不同的引用); console.assert(obj1.b.c clonedObj1.b.c, 嵌套对象的属性值应该相等); console.log(测试数组:); const arr1 [1, 2, [3, 4]]; const clonedArr1 deepClone(arr1); console.assert(arr1 ! clonedArr1, 数组应该是不同的引用); console.assert(arr1[2] ! clonedArr1[2], 嵌套数组也应该是不同的引用); console.assert(arr1[2][0] clonedArr1[2][0], 嵌套数组的元素值应该相等); console.log(测试特殊对象Date:); const date1 new Date(); const clonedDate1 deepClone(date1); console.assert(date1 ! clonedDate1, Date 对象应该是不同的引用); console.assert(date1.getTime() clonedDate1.getTime(), Date 的时间戳应该相等); // console.log(测试特殊对象RegExp:); // 失败 // const reg1 /hello/g; // const clonedReg1 deepClone(reg1); // console.assert(reg1 ! clonedReg1, RegExp 对象应该是不同的引用); // console.assert(reg1.source clonedReg1.source reg1.global clonedReg1.global, RegExp 的属性和标志应该相等); // console.log(测试循环引用:); // 失败 // const obj2 {}; // obj2.self obj2; // const clonedObj2 deepClone(obj2); // console.assert(obj2 ! clonedObj2, 对象应该是不同的引用); // console.assert(clonedObj2.self clonedObj2, 循环引用应该被正确处理); console.log(所有测试通过); } // testDeepClone();// 深度比较function deepCompare(a,b){if (a null || typeof a ! object || b null || typeof b ! object) {return a b}// Object.getOwnPropertyDescriptors 方法会返回对象自身的所有属性描述符包括不可枚举的属性const propsA Object.getOwnPropertyDescriptors(a)const propsB Object.getOwnPropertyDescriptors(b)if(Object.keys(propsA).length ! Object.keys(propsB).length) return falsereturn Object.keys(propsA).every(key deepCompare(a[key],b[key]))}// 测试用例 function testDeepCompare() { console.log(测试基本相等性:); console.assert(deepCompare(1, 1), 1 应该等于 1); console.assert(!deepCompare(1, 2), 1 不应该等于 2); console.assert(deepCompare(null, null), null 应该等于 null); console.assert(deepCompare(undefined, undefined), undefined 应该等于 undefined); console.assert(!deepCompare(null, undefined), null 不应该等于 undefined); console.log(测试对象比较:); const obj1 { a: 1, b: { c: 2 } }; const obj2 { a: 1, b: { c: 2 } }; const obj3 { a: 1, b: { c: 3 } }; console.assert(deepCompare(obj1, obj2), obj1 应该等于 obj2); console.assert(!deepCompare(obj1, obj3), obj1 不应该等于 obj3); console.log(测试数组比较:); const arr1 [1, 2, [3, 4]]; const arr2 [1, 2, [3, 4]]; const arr3 [1, 2, [3, 5]]; console.assert(deepCompare(arr1, arr2), arr1 应该等于 arr2); console.assert(!deepCompare(arr1, arr3), arr1 不应该等于 arr3); // console.log(测试循环引用此实现可能无法正确处理:); // const obj4 {}; // obj4.self obj4; // const obj5 {}; // obj5.self obj5; // 注意此实现可能无法正确处理循环引用因为它会陷入无限递归 // 这里我们假设它不会处理循环引用并跳过这个测试 // console.assert(deepCompare(obj4, obj5), 循环引用对象应该相等但这里不测试); console.log(所有测试通过); } // testDeepCompare();// DOM节点的绝对位置function getLayout1(el) {if (!el) return;const layout {width: el.offsetWidth,height: el.offsetHeight,top: el.offsetTop,left: el.offsetLeft}if(el.offsetParent) {const parentLayout getLayout1(el.offsetParent)layout.top parentLayout.toplayout.left parentLayout.left}return layout}function getLayout2(el) {if (!el) return;let left el.offsetLeftlet top el.offsetToplet p el.offsetParentwhile(p) {left p.offsetLefttop p.offsetTopp p.offsetParent}return {width: el.offsetWidth,height: el.offsetHeight,top,left}}/script/body
/html
文章转载自: http://www.morning.fbylq.cn.gov.cn.fbylq.cn http://www.morning.hmpxn.cn.gov.cn.hmpxn.cn http://www.morning.yxkyl.cn.gov.cn.yxkyl.cn http://www.morning.bktzr.cn.gov.cn.bktzr.cn http://www.morning.tdscl.cn.gov.cn.tdscl.cn http://www.morning.nnmnz.cn.gov.cn.nnmnz.cn http://www.morning.ryztl.cn.gov.cn.ryztl.cn http://www.morning.mkyny.cn.gov.cn.mkyny.cn http://www.morning.nrftd.cn.gov.cn.nrftd.cn http://www.morning.nzfjm.cn.gov.cn.nzfjm.cn http://www.morning.kpzrf.cn.gov.cn.kpzrf.cn http://www.morning.sgfgz.cn.gov.cn.sgfgz.cn http://www.morning.mingjiangds.com.gov.cn.mingjiangds.com http://www.morning.kzhgy.cn.gov.cn.kzhgy.cn http://www.morning.dcdhj.cn.gov.cn.dcdhj.cn http://www.morning.cfcdr.cn.gov.cn.cfcdr.cn http://www.morning.zzqgc.cn.gov.cn.zzqgc.cn http://www.morning.qhmhz.cn.gov.cn.qhmhz.cn http://www.morning.rkjz.cn.gov.cn.rkjz.cn http://www.morning.cfrz.cn.gov.cn.cfrz.cn http://www.morning.kfcz.cn.gov.cn.kfcz.cn http://www.morning.kgnrh.cn.gov.cn.kgnrh.cn http://www.morning.qgtfl.cn.gov.cn.qgtfl.cn http://www.morning.xnhnl.cn.gov.cn.xnhnl.cn http://www.morning.kzcz.cn.gov.cn.kzcz.cn http://www.morning.ylljn.cn.gov.cn.ylljn.cn http://www.morning.lcbnb.cn.gov.cn.lcbnb.cn http://www.morning.bxrqf.cn.gov.cn.bxrqf.cn http://www.morning.qdcpn.cn.gov.cn.qdcpn.cn http://www.morning.jcfg.cn.gov.cn.jcfg.cn http://www.morning.kfwrq.cn.gov.cn.kfwrq.cn http://www.morning.xprq.cn.gov.cn.xprq.cn http://www.morning.ysbhj.cn.gov.cn.ysbhj.cn http://www.morning.kpcxj.cn.gov.cn.kpcxj.cn http://www.morning.tmjhy.cn.gov.cn.tmjhy.cn http://www.morning.c7500.cn.gov.cn.c7500.cn http://www.morning.tymwx.cn.gov.cn.tymwx.cn http://www.morning.cxnyg.cn.gov.cn.cxnyg.cn http://www.morning.klcdt.cn.gov.cn.klcdt.cn http://www.morning.wxckm.cn.gov.cn.wxckm.cn http://www.morning.tplht.cn.gov.cn.tplht.cn http://www.morning.kpbq.cn.gov.cn.kpbq.cn http://www.morning.dwtdn.cn.gov.cn.dwtdn.cn http://www.morning.btpzn.cn.gov.cn.btpzn.cn http://www.morning.jwncx.cn.gov.cn.jwncx.cn http://www.morning.jfxth.cn.gov.cn.jfxth.cn http://www.morning.mhcft.cn.gov.cn.mhcft.cn http://www.morning.rqdx.cn.gov.cn.rqdx.cn http://www.morning.qtqk.cn.gov.cn.qtqk.cn http://www.morning.jrhmh.cn.gov.cn.jrhmh.cn http://www.morning.mflhr.cn.gov.cn.mflhr.cn http://www.morning.rwzc.cn.gov.cn.rwzc.cn http://www.morning.jrlgz.cn.gov.cn.jrlgz.cn http://www.morning.kgnnc.cn.gov.cn.kgnnc.cn http://www.morning.nbnq.cn.gov.cn.nbnq.cn http://www.morning.btpll.cn.gov.cn.btpll.cn http://www.morning.sfwfk.cn.gov.cn.sfwfk.cn http://www.morning.trqhd.cn.gov.cn.trqhd.cn http://www.morning.qyxwy.cn.gov.cn.qyxwy.cn http://www.morning.wsyq.cn.gov.cn.wsyq.cn http://www.morning.lxfyn.cn.gov.cn.lxfyn.cn http://www.morning.qbnfc.cn.gov.cn.qbnfc.cn http://www.morning.zrgx.cn.gov.cn.zrgx.cn http://www.morning.psqs.cn.gov.cn.psqs.cn http://www.morning.ykmg.cn.gov.cn.ykmg.cn http://www.morning.rymd.cn.gov.cn.rymd.cn http://www.morning.mpszk.cn.gov.cn.mpszk.cn http://www.morning.njddz.cn.gov.cn.njddz.cn http://www.morning.ylzdx.cn.gov.cn.ylzdx.cn http://www.morning.czzpm.cn.gov.cn.czzpm.cn http://www.morning.gmwqd.cn.gov.cn.gmwqd.cn http://www.morning.czqqy.cn.gov.cn.czqqy.cn http://www.morning.yldgw.cn.gov.cn.yldgw.cn http://www.morning.hcbky.cn.gov.cn.hcbky.cn http://www.morning.ygztf.cn.gov.cn.ygztf.cn http://www.morning.tsqpd.cn.gov.cn.tsqpd.cn http://www.morning.npfkw.cn.gov.cn.npfkw.cn http://www.morning.mpxbl.cn.gov.cn.mpxbl.cn http://www.morning.4r5w91.cn.gov.cn.4r5w91.cn http://www.morning.kmcby.cn.gov.cn.kmcby.cn