自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(8)
  • 收藏
  • 关注

原创 vue数据双项绑定缺陷(2.x)

vue数据双项绑定缺陷(2.x)使用Object.defineProperty()中get()、set()方法进行数据劫持data中变量为数组、对象时候,操作变量可能不会触发视图更新数组1.使用数组方法进行操作(push、pop、shift、unshift、splice、sort、reverse)会触发视图更新2.直接操作数组:使用索引为数组添加项 this.arr[2] = ‘abc’,[arr[1], arr.[2]] = [arr.[2],arr[1]], delete arr[1],改变数

2021-08-09 17:24:57 237

原创 JS二叉树输出全路径+二叉树全路径求和

二叉树输出全路径+二叉树全路径求和二叉树输出全路径function FullPathSum(tree){ if(!tree) return 0; let res = []; const dfs = (node, sum)=> { if(!node.left && !node.right) res.push(sum); if(node.left) dfs(node.left, node.left.val + sum); if(node.right) dfs(node

2021-08-07 15:17:47 349

原创 JS函数节流和防抖

JS函数节流和防抖节流: 动作绑定事件,动作发生后一段时间后触发事件,在这段时间内,如果动作又发生,则无视该动作,直到事件执行完后,才能重新触发。function throtte(func, time) { let activeTime = 0; return () => { const current = Date.now(); if (current - activeTime > time) { func.apply(this, ar

2021-08-06 16:04:46 52

原创 JS深拷贝

JS深拷贝(考虑循环调用)function deepClone(obj, hash = new Map()){ if(obj === null || typeof obj !== 'object') return obj; if(hash.has(obj)) return hash.get(obj); let res = Array.isArray(obj)?[]:{}; hash.set(obj, res); for(let key in obj){ if(obj.hasOwnProper

2021-08-06 11:29:26 60

原创 JS Instanceof 实现

手写Instanceoffunction myInstanceof(left, right){ let leftProto = left.__proto__; let rightProto = right.prototype; while(true){ if(leftProto === null) return false; if(leftProto === rightProto) return true; leftProto = leftProto.__proto__; }}验

2021-08-06 11:22:19 84

原创 JS Object.create()实现

JS Object.create()实现Object.myCreate = function(obj){ function F(){} F.prototype = obj; return new F();}

2021-08-06 11:16:31 84

原创 JS手写call、appl、bind及实现原理

手写call、appl、bind及实现原理callFunction.prototype.myCall = function(context){ context = context || window; let args = [...arguments].slice(1); let fn = Symbol('fn'); context[fn] = this; let res = context[fn](...args); Reflect.deleteProperty(context, fn);

2021-08-06 11:12:34 59

原创 JS手写柯里化

手写柯里化//支持多参数传递function curry(fn, ...args){ let len = fn.length; args = args || []; let _this = this; return function(){ let newArgs = [...args, ...arguments]; if(newArgs.length < len){ return curry.call(_this, fn, ...newArgs); }else{ r

2021-08-06 10:59:19 85

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除