2022年1月20日
摘要: // 闭包会引起内存泄漏// 只想要获取到desc的内容,可以将item设置位null let divs=document.querySelectorAll("div"); divs.forEach(function(item){ let desc=item.getAttribute("desc") 阅读全文
posted @ 2022-01-20 23:43 weakup 阅读(140) 评论(0) 推荐(0) 编辑
摘要: let arr=[1,23,4,5,6,7,21,0]; function between(a,b){ return function(v){ return v>=a && v<=b; } } console.log(arr.filter(between(0,9))); <button>后盾人</b 阅读全文
posted @ 2022-01-20 23:04 weakup 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 截取字符串 使用 slice、substr、substring 函数都可以截取字符串。 slice、substring 第二个参数为截取的结束位置 substr 第二个参数指定获取字符数量 let hd = 'houdunren.com'; console.log(hd.slice(3)); //d 阅读全文
posted @ 2022-01-20 19:20 weakup 阅读(545) 评论(0) 推荐(0) 编辑
摘要: typeof typeof 用于返回以下原始类型 基本类型:number/string/boolean function object undefined 可以使用typeof用于判断数据的类型 let a = 1; console.log(typeof a); //number let b = " 阅读全文
posted @ 2022-01-20 19:08 weakup 阅读(39) 评论(0) 推荐(0) 编辑
摘要: for/in 用于遍历对象的所有属性,for/in主要用于遍历对象,不建议用来遍历数组。 遍历数组操作 let hd = [ { title: "第一章 走进JAVASCRIPT黑洞", lesson: 3 }, { title: "ubuntu19.10 配置好用的编程工作站", lesson: 阅读全文
posted @ 2022-01-20 19:01 weakup 阅读(66) 评论(0) 推荐(0) 编辑