Shu-How Zの小窝

Loading...
上一页 1 ··· 20 21 22 23 24
摘要: 自定义事件总线 自定义事件总线属于一种观察者模式,其中包括三个角色: 口发布者(Publisher):发出事件(Event); 口订阅者(Subscriber):订阅事件(Event),并且会进行响应(Handler); 口事件总线(EventBus):无论是发布者还是订阅者都是通过事件总线作为中台 阅读全文
posted @ 2023-10-14 22:18 KooTeam 阅读(88) 评论(0) 推荐(0)
摘要: 深拷贝基本实现 1 深拷贝基本实现 2 function isObject(value){ 3 const valueType=typeof value 4 return (value!==null)&&(valueType 'object'||valueType 'function') 5 } 6 阅读全文
posted @ 2023-10-14 22:15 KooTeam 阅读(14) 评论(0) 推荐(0)
摘要: 防抖函数基本实现 1 function debounce(fn,delay){ 2 let timer=null 3 return function(...args){ 4 if(timer)clearTimeout(timer) 5 timer=setTimeout(() => { 6 fn.ap 阅读全文
posted @ 2023-10-14 17:52 KooTeam 阅读(28) 评论(0) 推荐(0)
摘要: 1 // ES6 ES2015 2 // https://promisesaplus.com 3 4 const PROMISE_STATUS_PENDING = 'pending' 5 const PROMISE_STATUS_FULFILLED = 'fulfilled' 6 const PRO 阅读全文
posted @ 2023-09-17 19:51 KooTeam 阅读(9) 评论(0) 推荐(0)
摘要: 响应式原理实现 1 // 保存当前需要收集的响应式函数 2 let activeReactiveFn=null 3 class Depend{ 4 constructor(){ 5 this.rectiveFns=new Set() 6 } 7 depend(){ 8 if(activeReacti 阅读全文
posted @ 2023-09-06 17:17 KooTeam 阅读(17) 评论(0) 推荐(0)
摘要: call 1 Function.prototype.myCall=function(thisArg,...args){ 2 let fn=this //隐式调用 3 thisArg=(thisArg!==null&&thisArg!==undefined)?Object(thisArg):windo 阅读全文
posted @ 2023-08-26 19:57 KooTeam 阅读(20) 评论(0) 推荐(0)
摘要: new操作符调用的作用如果一个函数被使用new操作符调用了,那么它会执行如下操作:1.在内存中创建一个新的对象(空对象);2.这个对象内部的[[prototype]]属性会被赋值为该构造函数的prototype属性;(后面详细讲);3.构造函数内部的this,会指向创建出来的新对象;4·执行函数的内 阅读全文
posted @ 2023-08-26 19:52 KooTeam 阅读(72) 评论(0) 推荐(0)
摘要: 理解组合函数 组合(Compose)函数是在JavaScript开发过程中一种对函数的使用技巧、模式: 口比如我们现在需要对某一个数据进行函数的调用,执行两个函数fn1和fn2,这两个函数是依次执行的; 口那么如果每次我们都需要进行两个函数的调用,操作上就会显得重复; 口那么是否可以将这两个函数组合 阅读全文
posted @ 2023-08-21 18:05 KooTeam 阅读(40) 评论(0) 推荐(0)
摘要: JavaScript柯里化 柯里化也是属于函数式编程里面一个非常重要的概念。 我们先来看一下维基百科的解释: 口在计算机科学中,柯里化(英语:Currying),又译为卡瑞化或加里化; 口是把接收多个参数的函数,变成接受一个单一参数(最初函数的第一个参数)的函数,并且返回接受余下的参数,而且返回结果 阅读全文
posted @ 2023-08-20 21:36 KooTeam 阅读(26) 评论(0) 推荐(0)
上一页 1 ··· 20 21 22 23 24