What is NodeJs? How node Js works

What is NodeJs? 

         Node js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.    

        lets developers use JavaScript to write command line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser. 

How NodeJs is work?

  • First of all, create a .JS file. because node JS is not any another language, it is an interpreter or running environment for a JavaScript language.(Test.js)
First node program (print hello world)

console.log('hello world')
Output in terminal
PS F:\nodejs> node app.js
hello world
Q.1 write a program to Add two no. in nodeJS.
var a = 3;
var b = 4;
console.log(`addition is: ${a+b}`)
Output
node add.js
addition is: 7
What is Webservice or Web Applications?

    Suppose you have a client which is your browser and then you have a web service which will be on a server.

     now this server need to have a unique IP address. normally whatever server you access it may be Google server or Facebook server every server will have the IP address and the only way to reach there is with the help of IP address. but then we don't know about the IP addresses right when you go to Google you don't mention the IP address what you mentioned is the domain name and then we have some Data service and between they will manage this naming conversion.

     so when you say google.com they will send request to a particular IP address so we have the entire table there so basically if you want to access any server you need to enter the IP address. 

one server can have multiple services

HTTP - 80(port no.)

FTP -21

SMTP - 25

        Every service have a different port no. and multiple server will have different IP address. each server differentiate between this services is with the help of port number.

        If you want to reach to a HTTP server to mention two things 

IP address:port Number

73.56.48.65:8080