Bhavi Digital

Bhavi Digital πŸš€ BhaviDigital is where I share whatever I’m learning in codingβ€”no fake hype, no heavy theory. Learn β†’ Build β†’ Share β†’ Grow together

I’m learning myself, and I share the same things to help learners like me build job-ready projects and grow step by step.

πŸš€ ES6 Modules vs CommonJS Modules in JavaScriptIf you're learning backend or modern JavaScript, you've probably seen the...
28/05/2026

πŸš€ ES6 Modules vs CommonJS Modules in JavaScript

If you're learning backend or modern JavaScript, you've probably seen these two ways of importing files πŸ‘‡

πŸ“Œ CommonJS Module
(Used mostly in older Node.js projects)

Export:

```js id="r3k7n1"
module.exports = add
```

Import:

```js id="v6m2x8"
const add = require("./math")
```

πŸ“Œ ES6 Module (ESM)
(Modern JavaScript standard)

Export:

```js id="b9q4p5"
export default add
```

Import:

```js id="c2z8w6"
import add from "./math.js"
```

⚑ Main Difference

βœ… CommonJS uses:
`require()` & `module.exports`

βœ… ES6 Modules use:
`import` & `export`

πŸ“Œ Why ES6 Modules are becoming popular?

βœ” Cleaner syntax
βœ” Better readability
βœ” Supported in modern browsers
βœ” Official JavaScript standard
βœ” Better for modern frameworks

πŸ“Œ Enable ES6 Modules in Node.js

Add this in `package.json`

```json id="y7f1k3"
{
"type": "module"
}
```

πŸ’‘ CommonJS is still widely used in older Node.js applications, but ES6 Modules are the future of JavaScript development.

If you’re starting today, learn both β€” but focus more on ES6 Modules πŸš€

POV: girl coders know the struggle πŸ˜‚πŸ’»πŸ’…Code perfect ho na ho… nails perfect hone chahiye ✨Balancing coding, aesthetics & ...
27/05/2026

POV: girl coders know the struggle πŸ˜‚πŸ’»πŸ’…
Code perfect ho na ho… nails perfect hone chahiye ✨
Balancing coding, aesthetics & main character energy πŸ˜ŒπŸ‘©β€πŸ’»


LINK:

POV: girl coders know the struggle πŸ˜‚πŸ’»πŸ’…Code perfect ho na ho… nails...

πŸš€ What is CORS in Backend Development?If you are working with frontend + backend projects, you’ve probably seen this err...
19/05/2026

πŸš€ What is CORS in Backend Development?
If you are working with frontend + backend projects, you’ve probably seen this error πŸ‘‡

❌ β€œBlocked by CORS Policy”
But what actually is CORS? πŸ€”

πŸ“Œ CORS stands for:
Cross-Origin Resource Sharing
It is a security feature used by browsers to control requests between different domains.

Example πŸ‘‡
Frontend:
http://localhost:3000
Backend API:
http://localhost:5000

Since both URLs have different ports, the browser treats them as different origins.
So when frontend tries to fetch data from backend, the browser blocks the request unless CORS is enabled.

βœ… Solution in Express.js
Install CORS package:
npm install cors

Use it in your server:
const express = require("express")
const cors = require("cors")
const app = express()
app.use(cors())

πŸŽ‰ Now your frontend can communicate with your backend successfully.

πŸ’‘ Why CORS is Important?
βœ… Protects APIs from unauthorized access
βœ… Adds browser-level security
βœ… Allows controlled data sharing between applications

Understanding CORS is one of the most important concepts for full-stack developers. πŸš€

πŸš€ Basic MongoDB Commands Every Beginner Should Know !If you’re starting your backend journey, learning MongoDB basics is...
18/05/2026

πŸš€ Basic MongoDB Commands Every Beginner Should Know !
If you’re starting your backend journey, learning MongoDB basics is a must. πŸ’»

Here are some MongoDB commands every developer should practice πŸ‘‡

πŸ“Œ Show all databases
show dbs

πŸ“Œ Create / Switch Database
use schoolDB

πŸ“Œ Show current database
db

πŸ“Œ Create Collection
db.createCollection("students")

πŸ“Œ Insert One Document
db.students.insertOne({
name: "Rahul",
age: 21
})

πŸ“Œ Insert Multiple Documents
db.students.insertMany([
{ name: "Aman", age: 20 },
{ name: "Priya", age: 22 }
])

πŸ“Œ Find All Data
db.students.find()

πŸ“Œ Find Specific Data
db.students.find({ age: 21 })

πŸ“Œ Update Data
db.students.updateOne(
{ name: "Rahul" },
{ $set: { age: 23 } }
)

πŸ“Œ Delete Data
db.students.deleteOne({ name: "Rahul" })

πŸ“Œ Delete Collection
db.students.drop()

πŸ’‘ MongoDB stores data in flexible JSON-like documents, making it beginner-friendly and powerful for modern web applications.

Start practicing these commands daily and your database skills will improve fast πŸš€

πŸš€ Understanding Path Params in Backend Development (Node.js + Express)If you are learning backend development, then you’...
17/05/2026

πŸš€ Understanding Path Params in Backend Development (Node.js + Express)

If you are learning backend development, then you’ll often hear about Path Params (also called Route Params).

But what exactly are they? πŸ€”
πŸ‘‰ Path Params are dynamic values passed directly inside the URL path.

Example:
/users/101
Here, 101 is the path parameter.

In Express.js, we define it like this:
app.get('/users/:id', (req, res) => {
console.log(req.params.id)
res.send(`User ID is ${req.params.id}`)
})

πŸ“Œ Output:
If user visits /users/101
β†’ Response: User ID is 101

πŸ’‘ Why Path Params are useful?
βœ… Fetch specific user data
βœ… Get product details
βœ… Dynamic routing
βœ… Build REST APIs efficiently

Examples from real-world apps:
πŸ”Ή /products/55
πŸ”Ή /students/12
πŸ”Ή /blogs/javascript-basics

⚑ Difference Between Path Params & Query Params
Path Params:
/users/101
Query Params:
/users?id=101

πŸ‘‰ Path Params are mostly used when identifying a specific resource.
If you're learning backend development, mastering routing concepts like this is super important. πŸš€

πŸ”₯ What Are Query Parameters in Backend ?If you’re learning backend development, understanding Query Params is super impo...
16/05/2026

πŸ”₯ What Are Query Parameters in Backend ?
If you’re learning backend development, understanding Query Params is super important because they are used in almost every real-world application.

━━━━━━━━━━━━━━━
πŸ“Œ What are Query Parameters?
━━━━━━━━━━━━━━━

Query Parameters are values passed inside the URL to send extra information to the server.
They start after the ? symbol in a URL.

Example πŸ‘‡
http://localhost:3000/products?category=mobile&brand=apple

Here:
category=mobile
brand=apple
These are Query Parameters.

━━━━━━━━━━━━━━━
πŸ“Œ Why Do We Use Query Params?
━━━━━━━━━━━━━━━

They help us:
βœ… Filter Data
βœ… Search Data
βœ… Sort Results
βœ… Handle Pagination
βœ… Send Small Optional Information

Real examples πŸ‘‡
/products?category=laptop
/products?page=2
/search?keyword=iphone
/users?sort=age

━━━━━━━━━━━━━━━
πŸ“Œ How To Access Query Params in Express.js?
━━━━━━━━━━━━━━━
Express.js gives us a built-in object called:
req.query

Example πŸ‘‡
const express = require("express");
const app = express();
app.get("/products", (req, res) => {
console.log(req.query);
res.send(req.query);
});
app.listen(3000);

πŸ’‘ Important:
Query params always come after ?
Multiple params are separated using &
Data received from query params is always in string format

Master Query Params and your backend skills will instantly improve πŸš€

Most beginners learn HTML + CSS + JavaScript…But when they start building real backend projects with Node.js, they get s...
14/05/2026

Most beginners learn HTML + CSS + JavaScript…
But when they start building real backend projects with Node.js, they get stuck on one thing:
πŸ‘‰ β€œHow do I show dynamic data inside HTML?”

That’s where **EJS (Embedded JavaScript)** becomes powerful.
EJS allows you to create dynamic web pages using plain HTML + JavaScript.

Instead of writing static HTML files, you can directly send data from your backend to your frontend.

Example πŸ‘‡
Welcome
If `userName = "Bhavi"`
Output becomes:
Welcome Bhavi

Why developers love EJS:
βœ… Easy to learn for beginners
βœ… Works perfectly with Node.js + Express
βœ… Reuse components using partials
βœ… Dynamic rendering becomes simple
βœ… Great for dashboards, admin panels, blogs, portals, etc.

One underrated feature in EJS πŸ‘‡
πŸ”₯ Partials

Instead of repeating navbar/footer on every page:

Write once β†’ use everywhere.

That’s how real-world projects stay clean and maintainable.
If you're learning backend development,
don’t just build APIs.

Learn how data connects with UI using templating engines like EJS.
Small skill.
Huge upgrade in real project development. πŸš€

πŸš€ Understanding the Path Module in Node.jsWhile working on backend projects, one module that makes file and folder handl...
13/05/2026

πŸš€ Understanding the Path Module in Node.js

While working on backend projects, one module that makes file and folder handling much easier is the Path Module in Node.js. πŸ“

Instead of manually writing file paths, the Path module helps create clean, reliable, and cross-platform paths.

✨ Common Uses:
βœ”οΈ Joining file paths
βœ”οΈ Getting file extensions
βœ”οΈ Finding directory names
βœ”οΈ Creating absolute paths
βœ”οΈ Working with uploads & static files

Example:
const path = require("path");
const filePath = path.join(__dirname, "public", "images", "photo.png");
console.log(filePath);

πŸ”₯ Why use it?
Because different operating systems use different path separators:

* Windows β†’ `\`
* Linux/Mac β†’ `/`

The Path module handles everything automatically, making your backend code more professional and error-free.

πŸ“Œ Useful Methods:

* `path.join()`
* `path.basename()`
* `path.dirname()`
* `path.extname()`
* `path.resolve()`

Small modules like this make a huge difference in real-world backend applications. πŸ’‘

πŸš€ JavaScript Coding QuizπŸ’‘ Comment your answer below!
12/05/2026

πŸš€ JavaScript Coding Quiz
πŸ’‘ Comment your answer below!

πŸš€ Understanding the OS Module in Node.js Backend πŸ’»When building backend applications with Node.js, knowing your server e...
11/05/2026

πŸš€ Understanding the OS Module in Node.js Backend πŸ’»
When building backend applications with Node.js, knowing your server environment is super important β€” and that’s where the OS Module comes in! πŸ”₯

The OS (Operating System) module is a built-in Node.js module that provides information about your system’s operating system, CPU, memory, network, and more.

πŸ”Ή Why Use the OS Module?
It helps developers:
βœ… Monitor system performance
βœ… Detect OS details
βœ… Build system-aware applications
βœ… Optimize backend performance

πŸ”Ή What Can You Get Using OS Module?
βœ”οΈ System platform (os.platform())
βœ”οΈ CPU architecture (os.arch())
βœ”οΈ Free memory (os.freemem())
βœ”οΈ Total memory (os.totalmem())
βœ”οΈ Hostname (os.hostname())
βœ”οΈ CPU information (os.cpus())
βœ”οΈ Home directory (os.homedir())

πŸ’‘ Example:
const os = require('os');
console.log("Platform:", os.platform());
console.log("CPU Architecture:", os.arch());
console.log("Free Memory:", os.freemem());
console.log("Total Memory:", os.totalmem());

⚑ The OS module helps backend developers understand the machine their application is running on β€” making apps smarter and more efficient.

Address

Tank Road
Delhi
110005

Website

Alerts

Be the first to know and let us send you an email when Bhavi Digital posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share

Category