Hello World with Node.js

Here, the obligatory Hell World example uses Node.js. Write the following line in a file called helloworld.js and save it:

console.log("Hello World");

And now to run it, execute the following command:

node helloworld.js

This should print Hello World on the console. All the JavaScript developers will immediately recognize that these are the steps we follow to print anything on the console while developing a web application.

What happens is that Node.js loads the JavaScript file in the JavaScript VM, provides an environment for its execution, and the VM interprets the script. When it gets console.log, it checks the environment for the console, which in this case is STDOUT, and writes Hello World to it.

But we are here to develop web applications, correct? So let's say hello to the Web!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset