Node js acts like Server-side JavaScript

In order to execute the JavaScript you intend to run in the backend, it needs to be interpreted and, well, executed. This is what Node.js does, by making use of Google’s V8 VM, the same runtime environment for JavaScript that Google Chrome uses.

Node.js ships with a lot of useful modules, so you don’t have to write everything from scratch, like for example something that outputs a string on the console.
Thus, Node.js is really two things: a runtime environment and a library.
Now node.js can be used for both front end and backend development with lots of code present.

In order to run node.js we require the following

  1. We want to serve web pages, therefore we need an HTTP server
  2. Our server will need to answer differently to requests, depending on which URL the request was asking for, thus we need some kind of router in order to map requests to request handlers

To fulfill the requests that arrived at the server and have been routed using the router, we need actual request handlers, the router probably should also treat any incoming POST data and give it to the request handlers in a convenient form, thus we need request data handling

We not only want to handle requests for URLs, we also want to display content when these URLs are requested, which means we need some kind of view logic the request handlers can use in order to send content to the user’s browser

  • Last but not least, the user will be able to upload images, so we are going to need some kind of upload handling which takes care of the details
  • The coding in node.js is relatively very clean and easy to maintain.
  • Different parts of the code are placed in different modules to organize them properly

 

Creating functions and calling them

function hello(word) {
console.log(word);
}

function execute(hello, value) {
hello(value);
}

execute(hello, “Hello”);

 

This is just a simple┬ánode.js ┬átutorial for beginners. for more information regarding node js please click on the <a href=”http://www.ojhasoftsolutions.in/node-tutorial”>node tutorial</a>