前端js
一枚韭菜
这个作者很懒,什么都没留下…
展开
-
阻止事件冒泡的三种方法
event.stopPropagation(); //1.停止事件冒泡,但是不会阻止默认行为 return false; // 2.阻止事件冒泡,也阻止了默认行为 event.preventDefault(); // 3.阻止默认行为,不阻止事件冒泡原创 2021-04-09 16:19:56 · 4204 阅读 · 2 评论 -
es6数组去重三种方法
处理数据中经常遇到的问题 //"Set" [...new Set(array)]; //"Filter" array.filter((item, index) => array.indexOf(item) === index); //"Reduce" array.reduce((unique, item) => unique.includes(item) ? unique : [...unique, item], []); 使用 Set set是ES6中引入的新的数据原创 2021-03-12 16:15:10 · 816 阅读 · 0 评论