摘要: /** * @param {string} url * @returns {Object} */ function param2Obj (url) { const search = url.split('?')[1] if (!search) { return {} } return JSON.pa 阅读全文
posted @ 2021-02-23 14:30 hwjun 阅读(66) 评论(0) 推荐(0) 编辑
摘要: var quickSort = function(arr) { if(arr.length<=1) return arr; var left = [], right = [], point = Math.floor(arr.length/2); var middle = arr.splice(poi 阅读全文
posted @ 2021-02-23 13:39 hwjun 阅读(32) 评论(0) 推荐(0) 编辑
摘要: function debounce(fn, wait, immediate) { let timer; return function() { const context = this; const args = arguments; timer && clearTimeout(timer); if 阅读全文
posted @ 2021-02-23 11:49 hwjun 阅读(41) 评论(0) 推荐(0) 编辑
摘要: Function.prototype.call = function(ctx) { var ctx = ctx || window; ctx.fn = this; var args = []; for(var i = 1, len = arguments.length; i < len; i++) 阅读全文
posted @ 2021-02-23 11:47 hwjun 阅读(46) 评论(0) 推荐(0) 编辑
摘要: /** * 深克隆 */ function deepClone(obj) { if(obj null) return null; if(typeof obj !== 'object') return obj; var newObj = obj instanceof Array ? [] : {}; 阅读全文
posted @ 2021-02-23 11:44 hwjun 阅读(60) 评论(0) 推荐(0) 编辑
摘要: function unique(arr) { var ret = []; var tmp = {}; for(var i = 0, len = arr.length; i < len; i++){ if(!tmp[typeof arr[i] + arr[i]]) { // 区分1 & '1' tmp 阅读全文
posted @ 2021-02-23 11:43 hwjun 阅读(19) 评论(0) 推荐(0) 编辑
摘要: class EventEmmiter { constructor() { this._events = {} } on(type, cb) { if(Array.isArray(type)) { type.forEach(tp => this.on(tp, cb)) } else { (this._ 阅读全文
posted @ 2021-02-23 11:35 hwjun 阅读(141) 评论(0) 推荐(0) 编辑