> On Nov 3, 2015, at 5:45 PM, Joseph Arrieta <[email protected]> wrote:
> 
> Hi guys,
> 
> I have a doubt if I have this a.js:
> 
> // a.js
> module.exports = {
>   someFunction: function() {
>     function innerFunction() {
>       //code here
>     }
>     innerFunction();
>   }
> }
> 
> and this other one b.js:
> 
> // b.js
> function outterFunction() {
> //code here
> }
> 
> module.exports = {
>   someFunction: function() {
>     innerFunction();
>   }
> }
> 
> NodeJS files are cached whenever we require them, that's so far so good, now 
> my question is does the innerFunction in file a.js its also cached? or 
> everytime I call 
> require('a.js').someFunction() the function innerFunction is redefined?

Yes and no.

It's a new function each time, though the parsing and compilation of it is 
cached, inside the runtime. If you were to return that function and compare it 
with another call, though, they'd be different.

This probably doesn't have any practical implications though that you could 
care about.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/8AC320B9-EFDD-44D8-BA6A-659B1CF5A238%40dinhe.net.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to