1
Beginner

Day 1: Introduction to Node.js

25 minutes2 examples
Progress
0%
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows you to run JavaScript on the server side, outside of web browsers.

What is Node.js?
Node.js is a platform that allows JavaScript to be executed on the server side. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.

Key Features of Node.js:
• Fast execution using Google's V8 engine
• Asynchronous programming with non-blocking I/O
• Single-threaded but highly scalable
• Large ecosystem of packages (npm)
• Cross-platform compatibility
• Built-in modules for file system, HTTP, and more

Why Use Node.js?
Node.js is perfect for building scalable network applications, APIs, real-time applications, and microservices. It's particularly popular for web development, IoT applications, and data streaming.

Node.js Architecture:
Node.js has a unique architecture with several layers:
- JavaScript Application Layer
- Node.js API Layer (fs, http, crypto, etc)
- V8 Engine (JavaScript Runtime)
- libuv (Event Loop)

Getting Started:
To start using Node.js, you need to install it on your system. Node.js comes with npm (Node Package Manager) which helps you manage dependencies and packages.

Interactive Examples

Hello World Program

A simple Node.js program to get started

JavaScript
console.log('Hello, Node.js!');

// Basic arithmetic
const a = 10;
const b = 20;
console.log('Sum:', a + b);
console.log('Product:', a * b);

// Working with strings
const firstName = 'John';
const lastName = 'Doe';
const fullName = firstName + ' ' + lastName;
console.log('Full Name:', fullName);

Output

Hello, Node.js!
Sum: 30
Product: 200
Full Name: John Doe

Explanation

This is a basic Node.js program that demonstrates console output, variables, and string concatenation. Run this with: node hello.js