Как получить элементы:
const links = document.querySelectorAll('a');
// или
const links = document.getElementsByTagName('a');
Как достать значение атрибута:
const getHref = el => el.getAttribute('href');
// или
const getHref = el => el.attributes.href.value;
Как собрать массив значений:
const hrefs = Array.from(links, getHref);
// или
const hrefs = Array.prototype.map.call(links, getHref);
// или
const hrefs = [];
for (const n of links) {
hrefs.push(getHref(n));
}
// или
const hrefs = [];
for (let i = 0; i < links.length; i++) {
hrefs[i] = getHref(links[i]);
}
// или
const hrefs = (function get(i, n = links.item(i)) {
return n ? [ getHref(n), ...get(i + 1) ] : [];
})(0);