Programming Paradigm:
1. Imperative Paradigm
Procedural Programming
Structured Programming
2. Declarative Paradigm
Functional Programming
Reactive Programming (e.g., RxJS)
3. Object-Oriented Programming
Class-based
Prototype-based
4. Event-Driven Programming
Based on event listeners, callbacks, DOM events, etc.
5. Asynchronous Programming (cross-paradigm)
Callback-based
Promise-based
async/await (syntactic sugar over Promises)
A programming paradigm is a style or way of programming.
Common paradigms include:
1. Imperative programming (writing step-by-step instructions)
2. Declarative Programming (What it is: Focuses on what to do, not how to do it.)
3. Event-driven programming (responding to events like clicks or messages)
4. Functional programming (using functions as the core building blocks)
5. Object-oriented programming (organizing code around objects)
Most Used Programming Paradigm:
Paradigm Common in JS? Description
Writing step-by-step logic like loops,
1. Imperative Programming Very common
conditionals, and variable updates.
What it is: Focuses on what to do, not how
2. Declarative Programming Very common to do it. Seen in Array.map, JSX in React,
etc.
Central to DOM events, and browser
3. Event-Driven Programming Core in JS
interactivity.
Emphasized in modern JS with arrow
functions, map, filter, reduce, immutability,
4. Functional Programming Increasingly popular
etc and avoid shared state & side effects
etc.
JavaScript supports both prototype-based
5. Object-Oriented Programming Still widely used and class-based OOP. Used in frameworks
and app architecture.
Imperative Programming v/s Declarative Programming:
Concept: You tell the computer how to Concept: You describe what you want, not how
do something step by step. to do it.
Think of it like: Giving someone exact Think of it like: Ordering a coffee — you just say
instructions to make a sandwich — "I want a cappuccino", you don't explain how to
one step at a time. make it.
Event-Driven Programming
Concept: Code responds to events like button clicks, form submissions, or messages.
Think of it like: A doorbell — your action (pressing the bell) triggers a response
(someone answers).
Functional Programming
Concept: Uses pure functions, avoids changing variables, and focuses on data
transformation.
Think of it like: A machine that always gives the same output for the same input.
Object-Oriented Programming (OOP)
Concept: Organize code into objects with properties (data) and methods (behavior).
Think of it like: A car object — it has properties (color, brand) and methods (drive()).