随笔分类 - js小方法
前端经常使用到的一些小方法
摘要:const addOne = x => x+1const addTwo = x => x+2addTwo(addOne(5)) //8const pipe = (fn1,fn2) => x => fn2(fn1(x))pipe(addOne,addTwo) //x => fn2(fn1(x))pip
阅读全文
摘要:原生js能够支持这几种类型数据格式之间的转换,先了解下Object.entries和Object.FromEntries这两个原生方法的作用。 Object.entries获取对象的键值对 Object.FromEntries把键值对列表转成对象 Object.entries和Object.from
阅读全文
摘要:const isEmpty = (obj: any) => { let isEmpty = false if (obj undefined || obj null || obj '') { isEmpty = true } else if (Array.isArray(obj) && obj.len
阅读全文
摘要:const getQueryString = (name) => { const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); const r = window.location.search.substr(1).match(reg); if
阅读全文

浙公网安备 33010602011771号