04 2020 档案
摘要:1.合理使用运行时依赖和开发依赖 作为开发者,要合理区分哪些插件是项目上线运行后需要的,哪些是用于打包编译,压缩而运行时并不需要的,进行分类安装。开发依赖不会被打包进最终的项目文件,能大大减少项目文件大小。 开发依赖在项目的package.json的devDependencies里,安装时使用的命令
阅读全文
摘要:var letterCombinations = function(digits) { if (!digits || digits ' ') return [] let alpList = ['abc','def','ghi','jkl','mno','pqrs','tuv','wxyz'] let
阅读全文
摘要:html代码: <div class="outer"> <div class="inner"></div> </div> 方法一:flex布局 .outer{ display: flex; justify-content: center; //水平居中 align-items: center //垂
阅读全文
摘要:class LazyMan { constructor(name){ this.nama = name; this.queue = []; this.queue.push(() => { console.log("Hi! This is " + name + "!"); this.next(); }
阅读全文
摘要:对于一个函数: function add(a,b,c){ return a + b + c } 我们希望实现一个效果,我们希望有另外一个函数curryingAdd,使得curryingAdd(1,2,3),curryingAdd(1,2)(3),curryingAdd(1)(2,3)和add(1,2
阅读全文
摘要:聊聊什么是jsonp 说到son大家应该是很熟悉的,jsonp和json只差了一个字母,那么他们是不是他们有着非常密切的关系呢?答案是确定的。jsonp全称”JSON with Padding“,意思应该是”填充的json“。那么问题就来了,填充指的是什么,怎么填充呢? 聊聊script标签 <sc
阅读全文
摘要:关于new的原理可参考:https://www.cnblogs.com/guanghe/p/11356347.html 下面是实现代码: function New(fn){ //fn是父类 var res = {}; if(fn.prototype !== null) { res.__proto__
阅读全文
摘要:关于instanceof的具体用法和原理,可参考:https://blog.csdn.net/LL18781132750/article/details/81115081 下面给出instanceof的实现代码: function myInstanceof(left,right){ var prot
阅读全文
摘要:var intToRoman = function(num) { let res = '' const numArr = [1000,900,500,400,100,90,50,40,10,9,5,4,1] const strArr = ['M','CM','D', 'CD','C','XC','L
阅读全文
摘要:var romanToInt = function(s) { var hashMap = { 'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10, 'V': 5, 'I': 1 }; var num = 0; for(var i = 0; i < s.le
阅读全文
摘要:现有一个父类: function People(name){ //属性 this.name = name //实例方法 this.sleep=function(){ console.log(this.name + '正在睡觉') } } //原型方法 People.prototype.eat = f
阅读全文
摘要:class EventEmitter { constructor(){ this.messageBox = {} } on(eventName,fn){ const callbacks = this.messageBox[eventName] || [] callbacks.push(fn) thi
阅读全文
摘要:call: Function.prototype.$call = function(context) { var context = context || window; context.fn = this; var args = Array.from(arguments).slice(1) con
阅读全文
摘要:Array.prototype.fakeFilter = function fakeFilter(fn, context) { if (typeof fn !== "function") { throw new TypeError(`${fn} is not a function`); } let
阅读全文
摘要:乱序 方法一:用sort生成随机序列 function mixArr(arr){ return arr.sort(() => { return Math.random() - 0.5; }) } 关于sort方法的参数请参考:https://www.xp.cn/b.php/95773.html 但这
阅读全文
摘要:防抖 概念:老实说,第一次听到这个词的时候觉得真的太生动了,我想大家从字面上就能get到他的意思。比如说点击出鼠标的时候不小心手抖了,一下子快速点了两次,但如果函数本身只需要触发一次,这样就导致了不确定的结果,所以,防抖的作用是限制函数在一定时间内只能触发一次,防止你”手抖“。当然这个手抖可能是无意
阅读全文
摘要:基本概念 盒模型由 margin + border + padding + content 四个属性组成,分为两种:W3C的标准盒模型和IE盒模型。 Margin(外边距) - 清除边框外的区域,外边距是透明的。 Border(边框) - 围绕在内边距和内容外的边框。 Padding(内边距) -
阅读全文

浙公网安备 33010602011771号