node.js - Javascript function inside another function a new instance created? -


I'm trying to figure out whether express.Router () is a router Returns a new example or not. So when I read the code I go into this basic Javascript question.

./ router / index.j

  var proto = module.exports = function (option) {options = options || {}; Function Router (Rick, Race, Next) {Router Handle (Rake, Race, Next); } // Mixon router class functions router .__ proto__ = proto; Router.param = {}; Router _param = []; Router.caseSensitive = options.caseSensitive; Router.strict = options.strict; Router.stack = []; Return router; };  

At any time when the external function is executed (I think it is via express.Router ()), is creating a new internal function? I believe this var router = function (...) {...} is so. But I am not sure about this matter.

Yes, it creates a new function object every time

Function declaration is effective A designated function is similar to expression that is hoisted:

  function f () {}  

versus

  var f = function f () {}; // hoisting  

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -