Could i inject a global variable into node context, like "document" in html's script, which any javascript files could access this variable, and it isn't needed to import or require it?
//var document = require('document') // i don't need to require it by myself
document.findById('111')
i would disagree about global-variables being bad-practice. they are oftentimes more elegant and simpler in solving a web-project's integration-level problems (as long as you pick long-enough names that are unique), than some of the contortionist, module-loading hacks i've seen which try to avoid it.
-kai
--
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 nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/5bdc3bac-3eb5-4b4a-9618-35217890ee87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 30 May 2018, at 1:11 PM, Zlatko <zlad...@gmail.com> wrote:
You could use the `global` object (https://nodejs.org/api/globals.html#globals_global) the same way you use `window` In the browser. But like in the browser, it's not recommended, in fact for most use cases it is actually discouraged.
But if you tell us why you need it, perhaps we can find a better pattern for you?
--
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 nodejs+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/dd471b9c-89ae-4dcb-8909-36035c15a31a%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/i_ALAnVa5xA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/45DD548A-067B-4DB9-B0C0-C2945F472DE0%40gmail.com.
For more options, visit https://groups.google.com/d/optout.