摘要: // 判断对象的方法 let obj6 = { a: 1, b: 2 }; // 1. typeof console.log(typeof obj6 "object"); // 2. instanceof console.log(obj6 instanceof Object true); // 3. 阅读全文
posted @ 2022-08-18 16:33 蓓蕾心晴 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 概念 1. 防抖(debounce):触发高频事件后 n 秒内函数只会执行一次,如果 n 秒内高频事件再次被触发,则重新计算时间举例:就好像在百度搜索时,每次输入之后都有联想词弹出,这个控制联想词的方法就不可能是输入框内容一改变就触发的,他一定是当你结束输入一段时间之后才会触发。 2.节流(thro 阅读全文
posted @ 2022-08-18 14:46 蓓蕾心晴 阅读(920) 评论(0) 推荐(0) 编辑
摘要: console.log("array flat"); // 1. 因为只有数组才有 concat 方法,所以这里必须写入初始值 空数组 只能打平一层 // const flat = (list) => list.reduce((a, b) => a.concat(b), []); // 2. 直接用 阅读全文
posted @ 2022-08-18 14:14 蓓蕾心晴 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 1. Array.isArray([]) // true 2. Object.prototype.toString.call([]) // '[object Array]' 3. [].constructor Array // true 4. [] instanceof Array // true 阅读全文
posted @ 2022-08-18 01:20 蓓蕾心晴 阅读(200) 评论(0) 推荐(0) 编辑
摘要: function reduce(list, fn, ...init) { let prev = init.length > 0 ? init[0] : list[0]; for (let i = init.length > 0 ? 0 : 1; i < list.length; i++) { pre 阅读全文
posted @ 2022-08-18 01:00 蓓蕾心晴 阅读(61) 评论(0) 推荐(0) 编辑