摘要: 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 s 的形式给出。 不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。 /** * @param {character[]} s * @return {void} Do not retur 阅读全文
posted @ 2023-01-30 21:35 671_MrSix 阅读(12) 评论(0) 推荐(0) 编辑
摘要: /** * 单链表的中点 */ 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) 编辑