It depends on what you want to do.
If you declare variables with var , then they are local to this function and cannot be accessed externally.
If you assign this variables, they will be set as properties of the context object on which the function is called.
So if, for example, if you write:
var obj = new Router();
then obj will have all the variables as properties, and you can change them. If you call
somobject.Router()
then all variables will be set as someobject properties.
Felix kling
source share