03 2021 档案
摘要:实现一个eventbus,包括emit,on,off,once方法: var Eventbus = (function () { let onlyBus; // 类型判断 let judgeType = function (param) { return Object.prototype.toStr
阅读全文
摘要:var type = []; // 输出[Object, Array] Object.propotype.toString().call(type); // 在原型链上查找能不能找到Array,因为所有变量的原型都是Object,所以不能判断{} type instantof Array // Ar
阅读全文
摘要:深度优先:从树节点的最左边第一个子节点开始遍历,如果当前节点还有子节点则继续往下遍历,无子节点则往右跳到下一个兄弟节点遍历: function dfs(node, nodeList = []) { nodeList.push(node); children = node.children; for(
阅读全文
摘要:防抖:一段时间内触发很多次的事件,限制到只执行一次,即只有最后一次触发事件生效,如页面滚动事件,代码: function debounce(func, wait) { let timer = null; //闭包 return () => { if (timer) { clearTimeout(ti
阅读全文

浙公网安备 33010602011771号