Requests have gotten better with "fetch", but unfortunately, the "modern" DOM API is quite bad in some parts, making lots of stuff unnecessarily verbose. On top of that, it's really odd that the DOM API is not compatible with for-of loops, which could have been a selling point.
I'm not sure what you mean by that? querySelectorAll returns an iterable. Also, your link is outdated. It doesn't include the fetch API which has enjoyed wide support for quite a while now.
Apparently my knowledge is outdated. Last time I tried to switch from jQuery to vanilla JS, the results of document.getElementsByTagName and others were not iterable with for-of.
$(".elements").css("color", "red")
versus
var selector = document.getElementsByClassName('elements');
selector.style.color = 'red';
const $ = document.querySelector;
$('.elements').style.color = 'red';
Which is only marginally more verbose.
You can however do:
document.querySelectorAll('a').forEach(a => a.style.color = 'red')
const $ = document.querySelector.bind(document);
or slightly less efficient, wrap in a function: const $ = function(x) { return document.querySelector(x) };
or if you want to be concise and don't need to support legacy IE: const $ = (x) => document.querySelector(x);
(and as pointed out already, you need querySelectorAll() and a loop for what jQuery does by default, though your example will work for a single element)> document.getElementsByClassName('comment').style
> undefined
You'd need a for loop right there I believe.