随笔分类 - javascript
摘要:Function.prototype.mycall = function () { const [first, ...rest] = arguments; const ctx = first || window; ctx.func = this; const ret = ctx.func(...re
阅读全文
摘要:js实现单例模式 1.最简单的方式 2.如果要求加上参数 3.改进一下 不使用call方法来 4.如果给出的参数没有就用默认值,有就用给出的let SingleTest = (function () { let _instance = null; 5.还有最后一个问题,有的人不适用new来创建对象,
阅读全文