A comprehensive, professional, and educational Vanilla JavaScript codebase that demonstrates ALL core and advanced JavaScript concepts. Perfect for beginners learning JavaScript and developers preparing for technical interviews.
- Overview
- Project Structure
- Getting Started
- Learning Path
- Topics Covered
- Mini Projects
- Interview Tips
- Best Practices
This repository is a complete learning resource for Vanilla JavaScript. Every major JavaScript topic is implemented with:
- β Clear, detailed comments
- β 2-3 real-world examples per topic
- β Console output demonstrations
- β DOM usage where applicable
- β Best practices and modern ES6+ syntax
- β Beginner-friendly but interview-ready code
No frameworks, no libraries - Pure Vanilla JavaScript!
vanilla-javascript/
β
βββ index.html # Main navigation and UI
βββ README.md # This file
βββ assets/
β βββ styles.css # Global styles
β
βββ basics/ # Fundamental concepts
β βββ variables.js
β βββ data-types.js
β βββ operators.js
β βββ type-coercion.js
β
βββ control-flow/ # Conditional logic and loops
β βββ if-else.js
β βββ switch.js
β βββ loops.js
β
βββ functions/ # Function types and patterns
β βββ function-types.js
β βββ parameters-vs-arguments.js
β βββ arrow-functions.js
β βββ iife.js
β βββ higher-order-functions.js
β
βββ scope/ # Scope and closures
β βββ scope-types.js
β βββ closures.js
β βββ this-keyword.js
β
βββ objects/ # Object manipulation
β βββ object-basics.js
β βββ object-methods.js
β βββ destructuring.js
β βββ copy-vs-reference.js
β
βββ arrays/ # Array methods and operations
β βββ array-methods.js
β βββ map-filter-reduce.js
β βββ find-sort.js
β βββ destructuring.js
β
βββ strings/ # String manipulation
β βββ string-methods.js
β βββ template-literals.js
β
βββ dom/ # DOM manipulation
β βββ selectors.js
β βββ dom-manipulation.js
β βββ create-elements.js
β βββ forms.js
β
βββ events/ # Event handling
β βββ event-basics.js
β βββ event-delegation.js
β βββ bubbling-capturing.js
β
βββ async/ # Asynchronous JavaScript
β βββ callbacks.js
β βββ promises.js
β βββ async-await.js
β βββ timers.js
β
βββ api/ # Fetch API
β βββ fetch-get.js
β βββ fetch-post.js
β βββ error-handling.js
β
βββ browser/ # Browser APIs
β βββ local-storage.js
β βββ session-storage.js
β βββ cookies.js
β βββ navigator-location.js
β
βββ error-handling/ # Error management
β βββ try-catch.js
β
βββ modules/ # ES6 Modules
β βββ math.js
β βββ main.js
β
βββ advanced/ # Advanced topics
β βββ hoisting.js
β βββ prototype.js
β βββ classes.js
β βββ inheritance.js
β βββ debouncing.js
β βββ throttling.js
β
βββ mini-projects/ # Practical projects
βββ todo-app/
βββ counter/
βββ modal/
- A modern web browser (Chrome, Firefox, Safari, Edge)
- A local web server (optional, but recommended)
-
Clone or download this repository
git clone https://github.com/yourusername/vanilla-javascript.git cd vanilla-javascript -
Open in browser
-
Simply open
index.htmlin your browser, OR -
Use a local server:
# Python 3 python -m http.server 8000 # Node.js (with http-server) npx http-server # VS Code Live Server extension # Right-click index.html β Open with Live Server
-
-
Navigate and Learn
- Click any button in the navigation to load and run examples
- Check the browser console for output
- View DOM output in the main area
-
Basics
- Variables (
basics/variables.js) - Data Types (
basics/data-types.js) - Operators (
basics/operators.js) - Type Coercion (
basics/type-coercion.js)
- Variables (
-
Control Flow
- If/Else (
control-flow/if-else.js) - Switch (
control-flow/switch.js) - Loops (
control-flow/loops.js)
- If/Else (
-
Functions
- Function Types (
functions/function-types.js) - Arrow Functions (
functions/arrow-functions.js)
- Function Types (
-
Arrays & Objects
- Array Methods (
arrays/array-methods.js) - Object Basics (
objects/object-basics.js)
- Array Methods (
-
DOM Basics
- Selectors (
dom/selectors.js) - DOM Manipulation (
dom/dom-manipulation.js)
- Selectors (
-
Advanced Functions
- Closures (
scope/closures.js) - Higher-Order Functions (
functions/higher-order-functions.js) - IIFE (
functions/iife.js)
- Closures (
-
Scope & Context
- Scope Types (
scope/scope-types.js) - This Keyword (
scope/this-keyword.js)
- Scope Types (
-
Array Operations
- Map, Filter, Reduce (
arrays/map-filter-reduce.js) - Find & Sort (
arrays/find-sort.js)
- Map, Filter, Reduce (
-
Events
- Event Basics (
events/event-basics.js) - Event Delegation (
events/event-delegation.js)
- Event Basics (
-
Async Basics
- Callbacks (
async/callbacks.js) - Promises (
async/promises.js)
- Callbacks (
-
Async/Await
- Async/Await (
async/async-await.js) - Timers (
async/timers.js)
- Async/Await (
-
APIs
- Fetch GET (
api/fetch-get.js) - Fetch POST (
api/fetch-post.js) - Error Handling (
api/error-handling.js)
- Fetch GET (
-
Advanced Concepts
- Prototypes (
advanced/prototype.js) - Classes (
advanced/classes.js) - Inheritance (
advanced/inheritance.js) - Hoisting (
advanced/hoisting.js)
- Prototypes (
-
Performance
- Debouncing (
advanced/debouncing.js) - Throttling (
advanced/throttling.js)
- Debouncing (
-
Modules
- ES6 Modules (
modules/main.js)
- ES6 Modules (
- β Variables (var, let, const)
- β Data Types (Primitives & Objects)
- β Operators (Arithmetic, Logical, Comparison)
- β Type Coercion & Truthy/Falsy
- β Control Flow (if/else, switch, loops)
- β Functions (All types)
- β Scope & Closures
- β This Keyword
- β Hoisting
- β Objects (Creation, Methods, Destructuring)
- β Arrays (Methods, Map/Filter/Reduce)
- β Strings (Methods, Template Literals)
- β Copy vs Reference
- β DOM Selectors
- β DOM Manipulation
- β Creating Elements
- β Form Handling
- β Event Listeners
- β Event Delegation
- β Bubbling & Capturing
- β Callbacks
- β Promises
- β Async/Await
- β Timers (setTimeout, setInterval)
- β Fetch API (GET, POST, Error Handling)
- β Local Storage
- β Session Storage
- β Cookies
- β Navigator & Location
- β Prototypes & Inheritance
- β ES6 Classes
- β ES6 Modules
- β Error Handling
- β Debouncing & Throttling
Three complete, functional projects demonstrating real-world JavaScript:
- Add, toggle, and delete todos
- Local storage persistence
- Clean, modern UI
- Increment, decrement, reset
- History tracking
- Local storage
- Multiple modal types
- Click outside to close
- Keyboard support (Escape key)
- Smooth animations
-
Closures
- See
scope/closures.jsfor examples - Understand lexical scope and closure patterns
- See
-
This Keyword
- See
scope/this-keyword.js - Know call, apply, bind
- See
-
Hoisting
- See
advanced/hoisting.js - Understand var vs let/const hoisting
- See
-
Prototypes & Inheritance
- See
advanced/prototype.jsandadvanced/inheritance.js - Know prototype chain
- See
-
Event Delegation
- See
events/event-delegation.js - Understand performance benefits
- See
-
Promises & Async/Await
- See
async/promises.jsandasync/async-await.js - Know Promise.all(), Promise.race()
- See
-
Map, Filter, Reduce
- See
arrays/map-filter-reduce.js - Essential for functional programming questions
- See
-
Debouncing & Throttling
- See
advanced/debouncing.jsandadvanced/throttling.js - Common performance optimization questions
- See
Try implementing these using the concepts in this repo:
- Reverse a string (using string methods)
- Find duplicates in array (using array methods)
- Implement debounce function (see advanced/debouncing.js)
- Flatten nested array (using reduce)
- Deep clone object (see objects/copy-vs-reference.js)
- Implement Promise.all (see async/promises.js)
This repository follows JavaScript best practices:
- Use
constandlet- Avoidvar - Arrow Functions - For cleaner syntax
- Template Literals - Instead of string concatenation
- Destructuring - For cleaner code
- Async/Await - Over callbacks when possible
- Error Handling - Always use try/catch
- Meaningful Names - Clear variable and function names
- Comments - Explain complex logic
- ES6+ Features - Modern JavaScript syntax
- No Global Pollution - Use modules and IIFE
Contributions are welcome! Feel free to:
- Add more examples
- Improve documentation
- Fix bugs
- Add more mini projects
This project is open source and available for educational purposes.
This repository is designed to be a comprehensive learning resource for JavaScript developers at all levels.
Happy Learning! π
Remember: The best way to learn is by doing. Try modifying the examples and building your own projects!