Aliasing document.querySelector and document.querySelectorAll [duplicate]

Hello I’m trying to alias the two functions from the title like so

const $ = document.querySelector;
const $$ = document.querySelectorAll;
$$("a")

But upon running $$("a") i get error Uncaught TypeError: Illegal invocation.

Why is that?