随笔分类 -  JS设计模式

摘要:http://www.ruanyifeng.com/blog/2013/09/finite-state_machine_for_javascript.html 阅读全文
posted @ 2020-06-20 19:52 TTtttt5 阅读(146) 评论(0) 推荐(0)
摘要:Function.prototype.before = function( beforefn ){ var __self = this; // 保存原函数的引用 return function(){ // 返回包含了原函数和新函数的"代理"函数 beforefn.apply( this, argum 阅读全文
posted @ 2020-06-20 11:53 TTtttt5 阅读(157) 评论(0) 推荐(0)
摘要:<button id="button">按我</button> <script> var MacroCommand = function () { return { commandsList: [], add: function (command) { console.log(command); t 阅读全文
posted @ 2020-06-19 11:21 TTtttt5 阅读(231) 评论(0) 推荐(0)
摘要:var button1 = document.getElementById("button1"); var button2 = document.getElementById("button2"); var button3 = document.getElementById("button3"); 阅读全文
posted @ 2020-06-19 09:44 TTtttt5 阅读(130) 评论(0) 推荐(0)
摘要:实战经常用的 先创建一个用于求乘积的函数: var mult = function(){ console.log( '开始计算乘积' ); var a = 1; for ( var i = 0, l = arguments.length; i < l; i++ ){ a = a * argument 阅读全文
posted @ 2020-06-18 22:27 TTtttt5 阅读(275) 评论(0) 推荐(0)
摘要:https://segmentfault.com/a/1190000017721211 // 在这里写 var strategies = { isNonEmpty(value, errorMsg) { if (value "") { return errorMsg; } }, minLength(v 阅读全文
posted @ 2020-06-18 18:33 TTtttt5 阅读(143) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-06-18 09:18 TTtttt5 阅读(138) 评论(0) 推荐(0)
摘要:https://zhuanlan.zhihu.com/p/75129004?from_voters_page=true 阅读全文
posted @ 2020-06-17 21:17 TTtttt5 阅读(92) 评论(0) 推荐(0)
摘要:https://www.cnblogs.com/chen-jie/p/JavaScript-Entrust.html 阅读全文
posted @ 2020-06-17 17:01 TTtttt5 阅读(85) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/KlausLily/article/details/103046377 const baseOperateController = function() { // 缓存对象 const cache = {}; // 基础函数 return function 阅读全文
posted @ 2020-06-17 11:58 TTtttt5 阅读(152) 评论(0) 推荐(0)
摘要:https://www.cnblogs.com/tugenhua0707/p/4780227.html 阅读全文
posted @ 2020-06-16 19:38 TTtttt5 阅读(106) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-06-16 01:50 TTtttt5 阅读(89) 评论(0) 推荐(0)
摘要:https://www.cnblogs.com/TomXu/archive/2012/04/16/2436460.html 阅读全文
posted @ 2020-06-15 22:11 TTtttt5 阅读(94) 评论(0) 推荐(0)
摘要:https://www.jianshu.com/p/11918dd0f694 阅读全文
posted @ 2020-06-15 17:23 TTtttt5 阅读(124) 评论(0) 推荐(0)
摘要:http://www.manongjc.com/article/42740.html // //书籍建造者类 // class BookBuilder { // constructor() { // this.name = ""; // this.author = ""; // this.price 阅读全文
posted @ 2020-06-15 14:53 TTtttt5 阅读(158) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-06-15 10:15 TTtttt5 阅读(125) 评论(0) 推荐(0)
摘要:const optionsAdded = {}; eventsListened.forEach(elt => { optionsAdded["on" + elt] = delegateAndEmit.call(this, elt); }); const eventsListened = ["Star 阅读全文
posted @ 2020-06-13 22:25 TTtttt5 阅读(279) 评论(0) 推荐(0)
摘要:function mergeHook ( parentVal, childVal ) { var res = childVal ? parentVal ? parentVal.concat(childVal) : Array.isArray(childVal) ? childVal : [child 阅读全文
posted @ 2020-06-12 21:54 TTtttt5 阅读(205) 评论(0) 推荐(0)
摘要:进阶函数柯里化 ...args这是柯里化,给fn传参的 阅读全文
posted @ 2020-06-01 09:27 TTtttt5 阅读(244) 评论(0) 推荐(0)