随笔分类 - JS
摘要:bind Function.prototype.myBind = function(context = window) { let obj = { ...context }; obj.fn = this; return obj.fn; }; call Function.prototype.myCal
阅读全文
摘要:class Node { constructor(elem) { this.elem = elem; this.next = null; } } class LinkedList { constructor() { this.head = null; this.length = 0; } // 末尾
阅读全文
摘要:1.扁平化数组 arr.flat(n),n表示扁平化的次数,为Infinity let arr = [1, [2, 3, [4, 5]]]; arr.flat(Infinity) function flatten(arr) { while(arr.some(item=>Array.isArray(i
阅读全文
摘要:防抖debounce 在事件被触发n秒后执行,如果在这n秒内又被触发,则重新计时。业务场景比如远程搜索;按钮提交,防止多次提交只执行最后一次; //防抖函数 const debounce = (fn,delay)=>{ let timer = null; return (...args)=>{ cl
阅读全文

浙公网安备 33010602011771号