At
the time of writing this tutorial, below are the global objects, functions available
in global space. These global objects are accessible by all the modules of
node.js API.
I will cover all the global
objects in my later posts.
a. Class: Buffer
b. __dirname
c. __filename
g. console
h. exports
i. global
j. module
k. process
l. require()
p. URL
q. URLSearchParams
Let
me explain with an example.
HelloWorld.js
global.console.log("Welcome to node.js programming")
C:\Users\krishna\Documents\nodejs\examples>node HelloWorld.js Welcome to node.js programming
Since
global namespace is available for all the node.js modules, you can directly refer
console in your source code.
HelloWorld.js
console.log("Welcome to node.js programming")
Note
a. You do not need to
include the global name space explicitly, it is included by default in all the
modules.
No comments:
Post a Comment