知乎贺老live

1 leetcode 考题

2 mdn 学习网站

练习 1 获取一个网页全部的标签

① document.getElementsByTagName('*')获取全部的nodeList,然后遍历并用一个对象保存(localName,或者tagName属性)

② document.querySelectorAll('*')获取全部的nodeList,然后遍历并用一个对象保存

③ 浏览器自带$,通过$$('*')也可达到统一的效果

现在我们可以用一行代码实现数组去重了

let array = Array.from(new Set([1, 1, 1, 2, 3, 2, 4]));

let nodeList, arrList, targetList;
[...nodeList] = document.getElementsByTagName('*');

arrList = nodeList.map( item => {
   return item.localName; 
})

targetList = Array.from(new Set(arrList));

console.log(targetList)

2 为访问的链接添加一个已读的标签

visited 只能操作和颜色有关的属性了

color, background-color, border-color, outline-color

原文地址:https://www.cnblogs.com/luguiqing/p/8125515.html