随笔分类 - js原生
摘要:共同点 改变this指向 不同点 1.call 立即执行,参数为call({},1,2,3) 2.bind 返回回调函数,参数为bind({},1,2,3)(), 3.apply 立即执行,参数为apply({},[1,2,3]),参数是一个数组
阅读全文
摘要:树形结构 let tree = [{ id: '01000000', text: '北京', children: [{ id: '01001000', text: '北京市', children: [ { id: '01001001', text: '西城区', children: null, },
阅读全文
摘要:all的使用 function getJSON(id) { return new Promise((res,rej)=>{ setTimeout(()=>{ res(id) },1000) }) } // 生成一个Promise对象的数组 const promises = [2, 3, 5, 7,
阅读全文
摘要:1、防抖 /** * 防抖,当某一事件触发结束后,然后再去触发相应的函数 * */ function debounce(func, ms = 1000) { let timer; return function (...args) { if (timer) { clearTimeout(timer)
阅读全文
摘要:计算加法与减法 /** * @params arg1 参与计算的参数1 * @params arg2 参与计算的参数2 * @params type 控制加减(true为减法,false为加法) * */ function accSub(arg1, arg2, type) { let r1, r2,
阅读全文
摘要:https://juejin.im/post/6844903568487497741 解析react源码
阅读全文
摘要:class Base { static instance(){ return new this() } name1(){ return getClassName(this) } static name2(){ return getClassName(new this()) } } class A e
阅读全文
摘要:function Node(element) { this.element = element; this.next = null; this.previous = null; }function LList() { this.head = new Node("head"); this.find =
阅读全文
摘要:class Person{ constructor(props,aaa) { console.log(props,aaa) }}var pp=new Person("111",222)console.log(pp.__proto__ Person.prototype)console.log(pp)c
阅读全文
摘要:基本类型 boolean:true和false,表示是否正确 number:浮点数 string:文本 array:数组,let list : number[] = [] or let list:Array<number> = [] enum:枚举,enum Color {Red,Blue}; va
阅读全文
摘要:var man={ name:"小明", age:18};if("age" in man){ console.log("man对象中含有age属性")}else { console.log("没")}age必须是一个字符串,才可以查找;如果不加双引号会报错;意思是查找对象中有没有这个元素,如果有,执
阅读全文

浙公网安备 33010602011771号