What I mean is does node.js have object that are global function methods of. Like this in browser:
function myGlobalFunction() { console.log(this === window); } myGlobalFunction(); => true
log(global. foo); //return undefined... @spex: It works the same in node and the browser. In both cases, if you do var foo = 42 in the global environment, you'll be able to access foo as a property of the global object, which is window in the browser and global in NodeJS.
js is a server-side JavaScript run-time environment. It's open-source, including Google's V8 engine, libuv for cross-platform compatibility, and a core library. Notably, Node. js does not expose a global "window" object, since it does not run within a browser.
Unlike the browser where Javascript is sandboxed for your safety, node. js has full access to the system like any other native application. This means you can read and write directly to/from the file system, have unrestricted access to the network, can execute software and more.
Window is the object of browser, it is not the object of javascript. The javascript objects are string, array, date etc.
The closest equivalent in node is global
. I'm not sure if it translates in all of the same ways, but if you open a REPL and type in this === global
, it will return true.
Here's a discussion on the global object, though some it the information may be deprecated as it's pretty old: 'Global' object in node.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With