I stumbled upon following code:
function $(id) {
return document.getElementById(id);
}
Sadly, I don't know what it does. The only thing I found about this code was here: Make alias to document.getElementById in Javascript
I stumbled upon following code:
function $(id) {
return document.getElementById(id);
}
Sadly, I don't know what it does. The only thing I found about this code was here: Make alias to document.getElementById in Javascript
$
is a valid identifier in JavaScript (read more here), you can use it for functions, variables and object properties. That being said, my experience makes me immediately think of jQuery, other developers might have this expectation too.
Back to your code: you define a function named $
returning a call to document.getElementById
. There is no catch here, you can use it like any other JavaScript function:
const element = $('my-id');