Functions are first-class objects in JavaScript, they aren't special like they are in some other languages. They're just objects that are callable. Since they're objects, you can pass them around:
function example() {
console.log("Hi there");
}
const e = example;
e(); // "Hi there"
You can also put additional properties on them (something that Express also does). Here's an example:
function example() {
console.log("Hi there");
}
example.prop = 42;
const e = example;
e(); // "Hi there"
console.log(example.prop); // 42
console.log(e.prop); // 42 -- since `e` and `example` both refer to the same function
Is it possible to do this with any type of variable?
JavaScript variables don't have a type as they do in strongly-typed languages. The value the variable holds has a type, but the variable doesn't; a variable can hold a number one moment, a string the next, a function after that...
function example() {
console.log("Hi there");
}
let e = example;
e(); // "Hi there"
e = 42;
console.log(e); // 42
e = "Hi there";
console.log(e); // "Hi there"
If you want variables, parameters, and such to have types (so you can't put a string in a variable that's expected to contain a number), consider using TypeScript, Flow, or even just JSDoc combined with robust IDE support. These layer a type system on top of JavaScript (to varying degrees).
Getting back to your question: You can do it with any variable, but not with any type of value. You can't call a number:
let e = 42;
e(); // TypeError: e is not a function
You can only call functions or other host-provided callable objects¹ (which don't absolutely have to be true functions, but it's uncommon now for hosts to provide callable objects that aren't actual functions, it was problematic).
¹ Specifically, in spec terms, any object that supports the [[Call]] internal operation.