<h1 id="foo"></h1> <h2 class="bar"></h2> <h2 class="bar"></h2>
const $ = function(e) {
const c = e[0];
const len = e.split(' ').length;
if (c === '#' && len === 1) {
return document.getElementById(e.slice(1));
} else {
return document.querySelector(e);
}
}
const $$ = function(e) {
return document.querySelectorAll(e);
};
$('#foo').textContent = 'Hello';
$$('.bar').forEach(function(x) {
x.textContent = 'world!'
});