app.get(name) vs app.get(path, [callback...], callback) in Express

express, node.js

Solution

It's the same function. `express` decides what to do based on the invocation.

The code for `get()` starts with:

if (1 == arguments.length) ...

If it matches the `get(name)` signature, it returns a previously `set()` value; if it matches the route signature, it binds a path to a function.

Problem

I am new to Express, from the API docs it seems we have two `app.get()` methods one to get the value of a variable, the other most of us are familiar with to handle http GET requests. What is the difference between these two? How does Express know which one we want? Are they actually the same function?

Original source