Tutorial
Introduction to Node js

Introduction to Node js and the Course

🎉

Read This on Github

This article is available on Github. You can read it there and contribute to it.
Github Link
Any Issue ?

⭐ What is Node.js?

Explain

🚨

In this article, for sure you will get many boring theory but trust me day by day you will fall in love with Node.js and you will be able to understand the theory behind it.

  • Node is not a Language.
  • This is a Server Environment.
  • Node.js can connect with the database.

Node.js can connect with the database because it is a server-side environment that can run JavaScript code and interact with various databases using drivers or modules. JavaScript, on the other hand, is mainly a client-side language that runs in the browser and cannot directly access the database for security reasons. To connect to the database from JavaScript, you need to use a backend service that can handle the database queries and send the results back to the browser.

  • Code and syntax are very similar to JavaScript But not exactly the same.
  • Node.js is free and open-source.
  • Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.

Chrome's V8 JavaScript engine is an open-source JavaScript engine developed by the Google Chrome team. It is written in C++ and is used to execute JavaScript code in web browsers, Node.js, and other applications. V8 compiles JavaScript code into machine code directly, making it very fast and efficient. It also includes features such as just-in-time (JIT) compilation, garbage collection, and support for modern JavaScript features.

⭐ Why do we use Node?

Explain

  • Node.js is commonly used for building APIs.
  • Node.js allows for seamless connection of databases to web and mobile applications.
  • Node.js is easy to understand for those who know JavaScript.
  • Node.js is incredibly fast for building APIs.
  • Node.js and JavaScript can be used for full-stack development.

⭐ History of Node.js

Explain

  • First Release: Node was first released on May 27, 2009 by Ryan Dahl (opens in a new tab), who was inspired by the event-driven and non-blocking I/O model of web browsers.
  • Current Version: The latest stable version of Node is 17.2.0, which was released on December 7, 2021. Node follows a semver (semantic versioning) scheme and releases a new major version every six months, with even-numbered versions receiving long-term support (LTS).
  • Written in: Node is mainly written in C, C++, and JavaScript. C and C++ are used to implement the core functionality and bindings to the V8 JavaScript engine, which executes the JavaScript code. JavaScript is used to write the standard library and most of the user-facing modules of Node.

For more information, you can visit the Node official website (opens in a new tab), the Node GitHub repository (opens in a new tab), or the Node documentation (opens in a new tab).

⭐ Is javascript and Node.js same?

Explain

JavaScript and Node.js are related but not the same. Here are some differences and similarities between them:

  • JavaScript and Node.js code syntax is same: Both JavaScript and Node.js use the same syntax, which is based on the ECMAScript (ES) standard. This means that the basic rules and structures of writing code are the same for both.
  • If you know JavaScript you can easily understand Node: Knowing JavaScript can help you learn Node.js faster, as you are already familiar with the syntax and some of the built-in objects and methods. However, you still need to learn the specific features and modules of Node.js, such as the event loop, streams, buffers, etc.
  • But both are not exactly the same: JavaScript and Node.js are different in terms of their environments, capabilities, and purposes. JavaScript is a scripting language that can run on any platform that supports a JavaScript engine, such as web browsers, mobile devices, etc. Node.js is a software platform that runs JavaScript on the server-side, using the V8 engine.
  • You can not connect JavaScript to DB: JavaScript by itself cannot connect to a database, as it does not have any built-in modules or libraries for database access. You need to use a third-party framework or library, such as jQuery, Angular, React, etc., to communicate with a database using JavaScript.
  • Node can connect with DB: Node.js can connect to a database, as it has many modules and libraries that support various types of databases, such as MongoDB, MySQL, PostgreSQL, etc. You can use the native Node.js modules, such as mysql or mongodb, or use a third-party framework or library, such as mongoose or sequelize, to connect to a database using Node.js.
  • Node.js runs on the server-side: Node.js is designed to run on the server-side, which means that it can handle requests from clients, process data, perform computations, and send responses back to the clients. Node.js can also act as a web server, using modules such as http or express.
  • JavaScript runs on the browser: JavaScript is mainly used to run on the browser, which means that it can manipulate the HTML and CSS elements of a web page, add interactivity, validate user input, and communicate with the server using AJAX. JavaScript can also run on other platforms, such as mobile devices, using frameworks such as React Native or Ionic.

Conclusion

Key PointJavaScriptNode.js
DefinitionA scripting language that can run on any platform that supports a JavaScript engine.A software platform that runs JavaScript on the server-side, using the V8 engine.
Database ConnectionCannot connect to a database by itself, needs a third-party framework or library.Can connect to a database, has many modules and libraries that support various types of databases.
Execution EnvironmentMainly runs on the browser, can also run on other platforms using frameworks.Runs on the server-side, can also act as a web server using modules.