Introduction to Node.js

Introduction to Node.js


In this tutorial, you’ll learn the importance of Nodejs and also understand the role & usage of Node.js. NodeJs was created to give us the possibility of running Javascript on this server-side. which means that we can understand requests may come to pass up on our server using javascript.

So, once you have Nodejs install then you can be able to respond to this request from the browser using javascript programming language.

The Nodejs is a javascript runtime. because You know javascript programming language typically used in the browser to manipulate your DOM. to manipulate the page which was loaded in the browser.

For example, to open a popup, a modal or add any kind of effects. because Javascript is a language that runs in the browser that allows you to interact with the page after it was loaded and it. thus, it is a crucial part when it comes to building interactive user interfaces in the browser.

Nodejs is a different version of javascript. it is basically built on javascript, it adds some features to it, is not capable of doing some other things you can do with javascript in the browser. so it basically takes javascript and puts it into a different environment. It allows you to run javascript code on the server.

Javascript Engine

So, it basically allows you to run javascript, not in the browser but anywhere else like a normal programming language. like normal programs on your computer or engine running somewhere on the Internet.

V8 simply means that the engine takes javascript code, the code running in your browser then or in Nodejs. also the Nodejs javascript code, it takes that javascript code and compiles it to machine code.

It does take your javascript code and compile it to machine code. because that is the code that runs on your computer and that can be handled efficiently.

Now, We’ll understand the role and usage of Node.js and why you use it and what you use it for. So, you use Node.js to run it on a server to write server-side code.

We have our users using a client computer with a browser, their mobile phone with a browser. We get our users using the browser and there we can use HTML, CSS, and javascript. the javascript in the browser to create webpages.

Then, they visit a page, and they send a request to do. so, for example, by entering a URL in the browser, a request sent to that URL.

Now, the server comes into play. So, we got our server. so, some computer running on the Internet which has the IP associated with that domain which is automatically resolved for us and on that server. then, we want to execute some code that does something with the incoming request and returns a response. often but not necessarily always as you will learn. this response is an HTML page which the browser then, in turn, can display.

Now, on the server, We connect to databases, for example, to fetch and store data. We do user authentication which we can only do on a place the user can’t access to make it more secure and avoid it being hacked.

We do it for input validation to see if a user entered a correct e-mail address, And in general, we have our business logic on the server.

Nodejs gives us and this is how we allow our users to work with the server through that request and response pattern, the direct access is not available.

So, the Nodejs is not limited to running code on a server. we can execute any javascript code with Nodejs and often that is code that runs on a server and execute upon incoming requests. but, you also often use Nodejs for other code, for example for local utility scripts or build tools.

javascript compile code

you actually used Nodejs indirectly a lot for all the build processes. these languages or frameworks needed because Nodejs is a great tool for writing utility scripts. You have access to the file system. so you can write and read and manipulate files and this allows you to do a lot of utility stuff on your computer that is never exposed to the public.

In general and that is the most popular thing you do with Nodejs though, you use it in the context of web development and server-side code.

So, you use it to run a server for example, with Nodejs you don’t write the code that is running on your server. you also write the server yourself, so the code that takes the incoming requests and routes them to your well other code.

Leave a Reply

Your email address will not be published. Required fields are marked *