上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 36 下一页
摘要: /** * 单链表的中点 */ const middleNode = (node = linkList) => { let slow = node, fast = node; while(fast && fast.next){ slow = slow.next fast = fast.next.ne 阅读全文
posted @ 2023-01-30 20:38 671_MrSix 阅读(6) 评论(0) 推荐(0) 编辑
摘要: /** * 单链表的倒数第k个节点 */ const linkList = { value: 1, next: { value: 2, next: { value: 3, next: { value: 4, next: { value: 5, next: { value: 6, next: { va 阅读全文
posted @ 2023-01-30 20:35 671_MrSix 阅读(1) 评论(0) 推荐(0) 编辑
摘要: // 页面垂直平滑滚动到指定滚动高度 const scrollSmoothTo = (position) => { if (!window.requestAnimationFrame) { window.requestAnimationFrame = function(callback, eleme 阅读全文
posted @ 2023-01-30 16:35 671_MrSix 阅读(7) 评论(0) 推荐(0) 编辑
摘要: Math.random()函数返回一个0~1之间的伪随机浮点数,其在V8中的实现原理是这样的: 为了保证足够的性能,Math.random()随机数并不是实时生成的,而是直接生成一组随机数(64个),并放在缓存中,当这一组随机数取完之后再重新生成一批,放在缓存中。 由于 Math.random()  阅读全文
posted @ 2023-01-30 16:21 671_MrSix 阅读(683) 评论(0) 推荐(0) 编辑
摘要: history.scrollRestoration支持下面两个属性值: auto 默认值,表示滚动位置会被存储 manual 表示滚动位置不会被存储 if (history.scrollRestoration) { history.scrollRestoration = 'manual'; } 阅读全文
posted @ 2023-01-30 16:02 671_MrSix 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 在Safari浏览器下,无论是桌面端Safari、还是IOS Safari,visibilitychange事件不总是触发的。 对于窗口最小化、tab隐藏等行为,visibilitychange事件是正常的,但是如果是点击页面的某个链接发生的当前页导航跳转,则visibilitychange事件不会 阅读全文
posted @ 2023-01-30 15:50 671_MrSix 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 语法 Array.prototype.copywithin(index, startIndex, endIndex) index 复制的数组项开始替换的起始索引值 start 复制的数组项的起始位置 end 复制的数组项的结束位置(不包含) 应用 删除数组中某一项 [].copyWithin(ind 阅读全文
posted @ 2023-01-29 23:06 671_MrSix 阅读(9) 评论(0) 推荐(0) 编辑
摘要: const CookieUtil = { get(name){ let cookieName = `${encodeURIComponent(name)}=` let cookieStart = document.cookie.indexOf(cookieName) let cookieValue 阅读全文
posted @ 2023-01-29 22:11 671_MrSix 阅读(14) 评论(0) 推荐(0) 编辑
摘要: /** * 十进制转换为2~36的任意进制 */ const baseConverter = (number = 12138, base = 2) => { if(base < 2 || base > 36) return new Error('进制参数错误') const stack = [] c 阅读全文
posted @ 2023-01-29 14:07 671_MrSix 阅读(73) 评论(0) 推荐(0) 编辑
摘要: 发现一个很有意思的事 /** * Array.of 是否为浅拷贝 */ const arr = [1, { x: 1 }] const arrOf = Array.of(...arr) console.log('arr',arr) arrOf[0] = 'zjy' arrOf[1].x = 'zjy 阅读全文
posted @ 2023-01-29 13:39 671_MrSix 阅读(10) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 36 下一页