Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And that is similar to require's behavior for properties on the returned object.

   const foo = require("foo"); // starts out as empty object

   exports.bar = function() {
     return foo.fn();
   }


Yes but the difference is that this:

let x = require('foo').x

of course, cannot do that. It's a small difference but it does make it easier to fall into the happy path in more cases.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: