摘要: var ops = { "plus": (x,y)=>x+y, "mul" : (x,y)=>x*y, "and" : (x,y)=>x&y } function operation(op, array) { return array.slice(1).reduce(ops[op], array[0]); } operation("plus", array); opera... 阅读全文
posted @ 2018-12-11 10:27 麦君 阅读(881) 评论(0) 推荐(0) 编辑
摘要: 最后输出10 阅读全文
posted @ 2018-11-22 14:09 麦君 阅读(346) 评论(0) 推荐(0) 编辑
摘要: export const ERROR_PROMISE_TIMEOUT = 'ERROR_PROMISE_TIMEOUT'; export default function (promise, timeout) { let timer = undefined; return Promise.race([ new Promise(function (resolve, reject)... 阅读全文
posted @ 2018-11-19 16:15 麦君 阅读(992) 评论(0) 推荐(0) 编辑
摘要: export default function (promiseProducer, params, interval, attemptTimes) { interval = typeof interval === "number" && interval >= 300 ? interval : 500; attemptTimes = typeof attemptTimes === "nu... 阅读全文
posted @ 2018-11-16 17:25 麦君 阅读(1284) 评论(0) 推荐(0) 编辑
摘要: 用循环遍历一棵树,需要借助一个栈,当栈为空时就遍历完了,栈里面存储下一个需要拷贝的节点 首先我们往栈里放入种子数据,key用来存储放哪一个父元素的那一个子元素拷贝对象 然后遍历当前节点下的子元素,如果是对象就放到栈里,否则直接拷贝 阅读全文
posted @ 2018-11-14 10:31 麦君 阅读(147) 评论(0) 推荐(0) 编辑
摘要: getPositionTop(node) { // 获取元素到顶部距离-通用方法 var top = node.offsetTop; var parent = node.offsetParent; while(parent != null) { top += parent.offsetTop; parent = parent.offsetP... 阅读全文
posted @ 2018-11-13 10:38 麦君 阅读(2993) 评论(0) 推荐(1) 编辑
摘要: $easeInSine: cubic-bezier(0.47, 0, 0.745, 0.715); $easeOutSine: cubic-bezier(0.39, 0.575, 0.565, 1); $easeInOutSine: cubic-bezier(0.445, 0.05, 0.55, 0 阅读全文
posted @ 2018-06-29 17:00 麦君 阅读(1319) 评论(0) 推荐(0) 编辑
摘要: type函数 首先我们要实现一个getType函数对元素进行类型判断,直接调用Object.prototype.toString 方法。 深拷贝(deepClone) 对于一个引用类型,如果直接将它赋值给另一个变量,由于这两个引用指向同一个地址,这时改变其中任何一个引用,另一个都会受到影响。当我们想 阅读全文
posted @ 2018-05-03 11:42 麦君 阅读(13214) 评论(0) 推荐(1) 编辑
摘要: 滑动屏幕 touchstart:接触屏幕时触发,touchmove:活动过程触发,touchend:离开屏幕时触发 首先获取手接触屏幕时的坐标X,Y 然后获取滑动的坐标,并使用后面的坐标减去前面的坐标,通过获取的值判断其滑动方向。因为手滑动方向一般不是水平或者垂直的,所以可使用Math.abs()进 阅读全文
posted @ 2018-03-05 15:17 麦君 阅读(603) 评论(0) 推荐(0) 编辑
摘要: 问题分类 滑动屏幕打开相应功能操作。 问题描述 1、用户手动滑动屏幕,根据滑动的方向,打开相应的功能(如:向上滑摇钱树经验明细,向下滑打开任务明细,向左滑打开聚宝盆物品查看等功能),滑动事件捕获问题。 2、大家都知道,划动都有角度问题,如:向330度方向滑动手机,要计算出它的方向问题。 3、HTML 阅读全文
posted @ 2018-03-05 15:16 麦君 阅读(203) 评论(0) 推荐(0) 编辑