Re:TinyJS – Shorten JavaScript QuerySelect with $ and $$
by qingcharles on Wednesday October 02, 2024 @04:47PM
(#41724825)
Thanks, this is the more useful bit of the code to me.
edit: how about this so you can use array functions too when you need?
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
window.$$$ = (selector) => Array.from(document.querySelectorAll(selector));
` window.$ = document.querySelector.bind(document) window.$$ = document.querySelectorAll.bind(document) `