摘要: 数组生成树型结构 阅读全文
posted @ 2020-05-09 10:19 炫冰G爱 阅读(978) 评论(0) 推荐(0) 编辑
摘要: 原文链接:https://juejin.im/post/5da1a04ae51d45783d6122bf 阅读全文
posted @ 2019-10-28 16:32 炫冰G爱 阅读(973) 评论(0) 推荐(0) 编辑
摘要: const formatUrl = (url: string, path: object) => { const reg = new RegExp(/\{(\w+)\}/, "g"); return url.replace(reg, ($0: any, $1: any) => { return pa 阅读全文
posted @ 2019-05-27 16:40 炫冰G爱 阅读(218) 评论(0) 推荐(0) 编辑
摘要: class Utils { swapArray(arr, index1, index2) { arr[index1] = arr.splice(index2, 1, arr[index1])[0]; return arr; }, // 上移 将当前数组index索引与后面一个元素互换位置,向数组后面移动一位 moveUp(arr, ind... 阅读全文
posted @ 2018-12-28 19:08 炫冰G爱 阅读(4017) 评论(0) 推荐(0) 编辑
摘要: function makeForm() { // 创建一个 form const tempForm = document.createElement("form"); tempForm.id = "tempForm"; tempForm.name = "tempForm"; // 添加到 body 中 document.body.appendChi... 阅读全文
posted @ 2018-12-28 19:03 炫冰G爱 阅读(4346) 评论(0) 推荐(0) 编辑
摘要: //匀速滚动function scroll(s,t){ let sp = 10/也可根据当前scrollTop动态改变sp的值,从而实现加速和减速滚动的效果 let cont = Number.parseInt(t / sp) let oneLong = s / cont let timer = setInterval(()=>{ console.log(cont) if(con... 阅读全文
posted @ 2018-07-30 10:27 炫冰G爱 阅读(3740) 评论(0) 推荐(0) 编辑
摘要: 1.数组的拷贝(二维数组的拷贝(深拷贝)方法,请看到最后。。。) //一纬数组,通过slice、concat,Array.from()方法可以实现 var arr1 = [1, 2], arr2 = arr1.slice(); console.log(arr1); //[1, 2] console. 阅读全文
posted @ 2018-05-08 09:20 炫冰G爱 阅读(333) 评论(0) 推荐(0) 编辑
摘要: //以下打印结果是5 var arr = [1,2,3,4,5] for(var i = 0; i < arr.length; i++){ arr[i] = function(){ alert(i) } } arr[1]() //一下打印结果是 1(使用了闭包) var arr = [1,2,3,4,5] for(var i = 0; i < arr.length; i++){ ... 阅读全文
posted @ 2018-05-07 14:12 炫冰G爱 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 1、var s1 = "get-element-by-id"; 给定这样一个连字符串,写一个function转换为驼峰命名法形式的字符串 getElementById 2、判断字符串是否包含数字 3、判断电话号码 4、判断是否符合指定格式 给定字符串str,检查其是否符合如下格式 5、判断是否符合U 阅读全文
posted @ 2018-05-02 17:43 炫冰G爱 阅读(228) 评论(0) 推荐(0) 编辑
摘要: //字符串编码转为unicode编码 //unicode编码转为字符串编码 阅读全文
posted @ 2018-04-26 13:04 炫冰G爱 阅读(19573) 评论(0) 推荐(0) 编辑