摘要: 记录贴 方式有几种吧,个人习惯这种写法 <button class="btn">自定义</button> let btn = document.querySelector(".btn") const myClick = new Event("ccx") btn.addEventListener("c 阅读全文
posted @ 2020-12-26 17:40 JS-Feng 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 记录贴 <button id="throttle">点我节流!</button> window.onload = function() { // 1、获取按钮,绑定点击事件 var myThrottle = document.getElementById("throttle"); myThrottl 阅读全文
posted @ 2020-12-26 17:36 JS-Feng 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 记录贴 // 手写new function Mynew(Fn,...args){ if(typeof Fn !== "function"){ throw "必须是方法体" } const obj = {} obj.__proto__ = Object.create(Fn.prototype) Fn. 阅读全文
posted @ 2020-12-26 17:32 JS-Feng 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 记录贴 // 手写浅拷贝 let arr = [1,2,3,4,5] let obj = { name:1 } function My(){ this.age = 0 My.prototype.nes = function(){ console.log("哈哈") } } let Obj = new 阅读全文
posted @ 2020-12-26 17:31 JS-Feng 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 记录贴 // 手写promise function MyPromise(fn){ let _this = this _this.status = "pending" _this.resolve_val = undefined _this.reject_val = undefined _this.re 阅读全文
posted @ 2020-12-26 17:27 JS-Feng 阅读(118) 评论(0) 推荐(0) 编辑