This repository is my personal collection of JavaScript notes, practice code snippets, and web development examples. It's built to help beginners and intermediate learners understand how JavaScript powers the web, and apply it in real-world scenarios like DOM manipulation, events, API handling, and more.
Explore this repo to learn, revise, and build your frontend development skills 💻✨
- JavaScript Basics
- DataTypes
- Conditional Statements
- Operators
- Type Coercion
- Objects and Arrays
- Loops
- Functions and Hoisting
- Document Object Model (DOM)
- Browser Object Model
- Regular Expressions
- OOPs in JS
- HTTP Requests
- jQuery Basics
- ES6 for ReactJS
- Basics of JS that matters
- Intermediate of JS that matters
- Advanced of JS that matters
- 🚀 Problem Solving Questions - Organized by Difficulty Level
- 0. Basics (Q1-Q40)
- Q1. Calculate sum of first N natural numbers - Functions
- Q2. Check if number is even or odd - Conditional Logic
- Q3. Reverse a string - String Manipulation
- Q4. Check if string is palindrome - String Manipulation
- Q5. Find factorial of a number - Mathematical Operations
- Q6. Generate Fibonacci sequence - Mathematical Operations
- Q7. Sum all numbers in array - Array Operations
- Q8. Find largest number in array - Array Operations
- Q9. Find minimum value in array - Array Operations
- Q10. Get last element of array - Array Operations
- Q11. Remove first element from array - Array Operations
- Q12. Reverse an array - Array Operations
- Q13. Create arrow function - Functions
- Q14. Add property to object - Objects
- Q15. Delete property from object - Objects
- Q16. Create object and print property - Objects
- Q17. Convert string to array of words - String/Array Conversion
- Q18. Write switch statement - Conditional Logic
- Q19. Convert Celsius to Fahrenheit - Mathematical Operations
- Q20. Convert Fahrenheit to Celsius - Mathematical Operations
- Q21. Check if number is prime - Mathematical Operations
- Q22. Calculate power of a number - Mathematical Operations
- Q23. Find words containing specific letter and its position - String Analysis
- Q24. Reverse a number (1234 → 4321) - Mathematical Operations
- Q25. Sort array of characters alphabetically - Array Sorting
- Q26. Print right triangle star pattern - Pattern Problems
- Q27. Print inverted star triangle - Pattern Problems
- Q28. Print pyramid star pattern - Pattern Problems
- Q29. Print diamond star pattern - Pattern Problems
- Q30. Print number triangle pattern - Pattern Problems
- Q31. Print Floyd's triangle - Pattern Problems
- Q32. Count digits in a number - Mathematical Operations
- Q33. Find missing number in array - Array Operations
- Q34. Swap two numbers without third variable - Mathematical Operations
- Q35. Check if year is leap year - Conditional Logic
- Q36. Find GCD of two numbers - Mathematical Operations
- Q37. Find LCM of two numbers - Mathematical Operations
- Q38. Print multiplication table - Loops
- Q39. Count words in a sentence - String Analysis
- Q40. Remove spaces from string - String Manipulation
- 1. Medium (Q41-Q74)
- Q41. Use callback function - Advanced Functions
- Q42. Filter even numbers from array - Array Methods
- Q43. Use map function on array - Array Methods
- Q44. Sort array in ascending order - Array Methods
- Q45. Sort array in descending order - Array Methods
- Q46. Sort array of strings alphabetically - Array Methods
- Q47. Remove duplicates from array - Array Methods
- Q48. Remove falsy values from array - Array Methods
- Q49. Merge two arrays - Array Methods
- Q50. Find intersection of two arrays - Array Methods
- Q51. Find union of two arrays - Array Methods
- Q52. Merge arrays alternating elements - Array Methods
- Q53. Count character occurrences in string - String Analysis
- Q54. Count vowels in string - String Analysis
- Q55. Check if string contains substring - String Analysis
- Q56. Find first non-repeated character - String Analysis
- Q57. Find longest word in string - String Analysis
- Q58. Get unique characters from string - String Analysis
- Q59. Capitalize first letter of each word - String Manipulation
- Q60. Convert string to title case - String Manipulation
- Q61. Convert array of strings to uppercase - Array/String Operations
- Q62. Check if two strings are anagrams - String Analysis
- Q63. Find frequency of elements in array - Array Analysis
- Q64. Find max difference between array elements - Array Analysis
- Q65. Find largest and smallest in array - Array Analysis
- Q66. Count occurrences of each character - String Analysis
- Q67. Calculate average of array numbers - Array Operations
- Q68. Find index of element in array - Array Operations
- Q69. Find second largest number in array - Array Analysis
- Q70. Group array elements by condition - Array Methods
- Q71. Calculate factorial using recursion - Recursion
- Q72. Create simple class - OOP
- Q73. Parse and stringify JSON - JSON Operations
- Q74. Convert object to array - Object/Array Conversion
- 2. Advanced (Q75-Q90)
- Q75. Implement debounce function - Advanced Functions
- Q76. Sort array of objects by key - Advanced Array Operations
- Q77. Implement deep clone function - Advanced Objects
- Q78. Merge two sorted arrays without built-in sort - Advanced Array Operations
- Q79. Check palindrome ignoring case and punctuation - Advanced String Operations
- Q80. Create linked list class - Data Structures
- Q81. Flatten nested array - Advanced Array Operations
- Q82. Check if strings are anagrams (advanced) - Advanced String Analysis
- Q83. Fibonacci with memoization - Optimization/Memoization
- Q84. Implement binary search - Algorithms
- Q85. Rotate array by r positions - Array Algorithms
- Q86. Reverse words in sentence without built-in reverse - Advanced String Manipulation
- Q87. Find second smallest element in array - Advanced Array Analysis
- Q88. Generate random alphanumeric string - Utility Functions
- Q89. Convert number to Roman numerals - Advanced Mathematical Operations
- Q90. Find largest element in nested array - Advanced Array Operations
- 3. Practical (Q91-Q99)
- Q91. Create countdown timer - DOM/Timers
- Q92. Generate random integer - Utility Functions
- Q93. Find longest word in sentence - String Analysis
- Q94. Truncate string - String Manipulation
- Q95. Check for unique characters - String Analysis
- Q96. Generate random password - Security/Utility
- Q97. Count word occurrences - String Analysis
- Q98. Dynamically insert DOM components - DOM Manipulation
- Q99. Analyze code output - Code Analysis
- DSA in JS
- 0. Basics (Q1-Q40)
# | Topic | Summary |
---|---|---|
1 | JavaScript Basics | Core syntax, comments, variable declarations (var , let , const ), and environment setup (Browser, Node.js, VS Code). |
2 | Data Types | Primitive (String, Number, Boolean, Null, Undefined, Symbol, BigInt) and Non-Primitive (Object, Array, Function, Map, Set, JSON). |
3 | Conditional Statements | if, else if, else, switch statements; logical operators used in decision-making. |
4 | Operators | Arithmetic, Assignment, Comparison, Logical, Bitwise, Ternary, typeof, delete, and precedence rules. |
5 | Type Coercion | Implicit vs Explicit conversion; avoid bugs using === and type conversion functions. |
6 | Objects and Arrays | Object literals, methods, array operations (push , map , filter , reduce ), Map, Set, JSON structures. |
7 | Loops | for, while, do...while, for...in, for...of; control flow using break , continue . |
8 | Functions and Hoisting | Function declaration/expression, arrow functions, scope (global, block, function), hoisting, closures, IIFE. |
9 | Document Object Model (DOM) | Selecting and manipulating HTML elements, addEventListener , event bubbling, capturing, delegation. |
10 | Browser Object Model (BOM) | Interacting with browser APIs: window , location , navigator , history , screen . |
11 | Regular Expressions | Pattern matching using test , exec , match , replace for string validation and search. |
12 | OOP in JavaScript | Objects, constructors, prototypes, ES6 classes, inheritance, encapsulation, polymorphism. |
13 | HTTP Requests (AJAX, Fetch, Promises) | Sending/receiving data using XMLHttpRequest , fetch() , Promises, async/await , and error handling. |
14 | jQuery Basics | DOM selection, manipulation, event handling, and AJAX with simplified syntax and cross-browser support. |
15 | ES6+ for ReactJS | let/const, arrow functions, destructuring, template literals, spread/rest, modules, Promises, async/await. |
16 | Asynchronous JavaScript | Event loop, task queue, callbacks, Promises, async/await , and proper error handling. |
17 | Advanced Function Concepts | this keyword, call , apply , bind , closures, higher-order functions, IIFE. |
18 | Design Patterns | Reusable solutions like Singleton, Module, Observer, Factory for structuring scalable applications. |
19 | Functional Programming in JS | Pure functions, immutability, first-class functions, higher-order functions, function composition. |
20 | Code Quality and Best Practices | "use strict" , linting tools, debugging, testing practices to write reliable, maintainable code. |
21 | Tooling | npm, Babel, Webpack, Parcel, Prettier, ESLint, and testing frameworks like Jest, Mocha. |
22 | Project Structure and Architecture | Modular folder structure, dependency management, scalability, separation of concerns. |
23 | Web APIs | Local Storage, Session Storage, IndexedDB, Web Workers, Service Workers, Notifications. |
24 | Performance Optimization | Reducing DOM manipulation, debouncing/throttling, lazy loading, profiling with DevTools. |
25 | Event Handling & Types | Click events: click , dblclick , contextmenu , mousedown , mouseup . Total 15+ mouse events, 13+ keyboard events, 8+ form events, 6+ window events. |
26 | JavaScript Engine & Execution | V8 engine, Call Stack, Memory Heap, Event Loop phases (Call Stack → Web APIs → Callback Queue → Event Loop). |
27 | Scope and Context | Global, Function, Block scope. Lexical scoping, this binding (implicit, explicit, new, arrow), execution context creation. |
28 | Memory Management | Garbage Collection, Memory leaks, Stack vs Heap memory, Reference counting, Mark-and-sweep algorithm. |
29 | Error Handling | try-catch-finally, Error types (SyntaxError, ReferenceError, TypeError), Custom errors, Promise error handling. |
30 | Prototype and Inheritance | Prototype chain, __proto__ , Object.create() , Constructor functions, ES6 classes, super keyword. |
31 | Array Methods (Advanced) | map , filter , reduce , forEach , find , some , every , flatMap , reduceRight . Method chaining patterns. |
32 | String Methods (Advanced) | slice , substring , substr , split , replace , match , search , Template literals, Tagged templates. |
33 | JSON and Serialization | JSON.parse() , JSON.stringify() , Circular reference handling, Custom toJSON methods, Data transformation. |
34 | Modules and Imports | ES6 modules (import /export ), CommonJS (require /module.exports ), AMD, UMD, Dynamic imports. |
35 | Timing Functions | setTimeout , setInterval , clearTimeout , clearInterval , requestAnimationFrame , Debouncing vs Throttling. |
36 | Data Structures in JS | Map, Set, WeakMap, WeakSet differences, Symbol usage, Iterator protocol, Generator functions. |
37 | Security in JavaScript | XSS prevention, CSRF, Content Security Policy, Input validation, Secure coding practices. |
38 | Browser Storage | localStorage vs sessionStorage vs cookies. Storage events, Storage limits, IndexedDB for large data. |
39 | Network and HTTP | HTTP methods, Status codes, CORS, Request/Response headers, REST API patterns, GraphQL basics. |
40 | Testing JavaScript | Unit testing (Jest), Integration testing, Mocking, Test-driven development, Code coverage. |
41 | Closures and Scope Chain | Advanced closure patterns, module pattern, private variables, scope pollution prevention, lexical environment chains. |
42 | Event Loop Deep Dive | Microtasks vs Macrotasks, Promise queue, setTimeout vs setImmediate, process.nextTick, task prioritization. |
43 | Proxy and Reflect API | Object interception, meta-programming, property access control, validation, data binding patterns. |
44 | Symbols and Well-known Symbols | Symbol.iterator, Symbol.asyncIterator, Symbol.toPrimitive, creating private properties, preventing name collisions. |
45 | WeakMap and WeakSet Use Cases | Memory management, private data storage, DOM node association, preventing memory leaks in large applications. |
46 | Intersection Observer API | Lazy loading images, infinite scrolling, viewport detection, performance optimization for large lists. |
47 | Mutation Observer API | DOM change detection, react to dynamic content, monitoring element modifications, debugging DOM changes. |
48 | Custom Elements (Web Components) | Creating reusable components, Shadow DOM, HTML templates, encapsulation, framework-agnostic components. |
49 | File API and Blob Handling | File upload, reading files, creating downloads, image processing, drag-and-drop file handling. |
50 | Canvas and WebGL Basics | 2D graphics, image manipulation, data visualization, basic game development, drawing operations. |
51 | Geolocation and Device APIs | GPS location, device orientation, camera access, microphone, notification permissions. |
52 | WebSocket and Real-time Communication | Live chat, real-time updates, server-sent events, bidirectional communication, connection management. |
53 | TypeScript Fundamentals | Type annotations, interfaces, generics, strict mode, migration from JavaScript, better IDE support. |
54 | Build Tools and Module Bundlers | Webpack configuration, Vite, Rollup, code splitting, tree shaking, hot module replacement. |
55 | Progressive Web Apps (PWA) | Service workers, manifest files, offline functionality, app-like experience, push notifications. |
56 | HTTP Caching Strategies | Cache headers, ETags, cache validation, CDN usage, browser caching, performance optimization. |
57 | Authentication and JWT | Token-based auth, refresh tokens, secure storage, OAuth flows, session management. |
58 | Form Validation and Accessibility | Custom validation, ARIA attributes, screen reader support, keyboard navigation, semantic HTML. |
59 | Internationalization (i18n) | Multi-language support, date/number formatting, locale-specific content, RTL languages. |
60 | Performance Monitoring | Core Web Vitals, FCP, LCP, CLS, FID, performance.mark(), User Timing API, real user monitoring. |
- JavaScript is a high-level, interpreted programming language.
- Runs in the browser and can interact with the DOM.
- Used for client-side and (with Node.js) server-side scripting.
- Syntax, Statements, and Comments
- Variables:
var
,let
,const
- Running JS: Browser, Node.js
- Environment Setup: Node.js, npm, VS Code
- Role of JS: Client-side, Server-side, Web Standards
Click to expand example
// This is a single-line comment
/*
This is a
multi-line comment
*/
console.log("Hello, JavaScript!");
Click to expand example
var city = "Mumbai"; // function scoped
let name = "Ayush"; // block scoped
const age = 23; // block scoped and can't be reassigned
Click to expand example
In Browser:
<script>
alert("Running in the browser!");
</script>
In Node.js:
// Save this in a file named app.js
console.log("Running in Node.js");
// Run: node app.js
Click to expand setup
- Download and install Node.js
- Use
npm
to install packages:npm install express
- Use Visual Studio Code as your code editor.
Click to expand explanation
- Client-side: Form validations, UI interactivity, AJAX requests.
- Server-side (Node.js): APIs, backend logic, database interactions.
- Web Standards: JavaScript is a core part of HTML/CSS/JS stack.
- String -
"hello"
- Number -
42
,3.14
- Boolean -
true
orfalse
- Undefined - variable declared but not assigned
- Null - intentionally empty value
- Symbol (ES6)
- BigInt - large integers beyond 2^53-1
- Objects:
{ key: value }
- Arrays:
[1, 2, 3]
- Functions
- JSON
- Maps and Sets
- `if`, `else if`, `else`
- `switch`
- Logical Operators in Conditions
if (score > 90) {
console.log("Excellent");
} else {
console.log("Keep trying");
}
- **Arithmetic**: `+`, `-`, `*`, `/`, `%`
- **Assignment**: `=`, `+=`, `-=`, etc.
- **Comparison**: `==`, `===`, `!=`, `!==`, `>`, `<`
- **Logical**: `&&`, `||`, `!`
- **Bitwise**,
- **Ternary (`? :`)**,
- **typeof**,
- **delete**
- Operator Precedence and Grouping
- Implicit vs Explicit Coercion
- JS automatically converts types when needed.
- `"5" + 2` → `'52'`
- `"5" - 2` → `3`
- Best Practices (`===`, `parseInt()`, `Boolean()`)
- Object Literals, Properties, Methods
- Arrays and Array Methods: `map`, `filter`, `reduce`
- Maps and Sets
- JSON as Data Structure
let user = {
name: "Ayush",
age: 23,
greet: function() {
return `Hello, ${this.name}`;
}
};
let colors = ["red", "blue", "green"];
colors.push("yellow");
- for, while, do...while, for...in, for...of
- Loop Control: `break`, `continue`
for (let i = 0; i < 5; i++) {
console.log(i);
}
- Function Declaration, Expression, Arrow Functions
- Hoisting: Functions vs Variables
- Scope: Global, Function, Block
- Lexical Scope and Closures
- IIFE (Immediately Invoked Function Expressions)
- Function Declaration
function greet() {
return "Hello";
}
- Function Expression
const greet = function() { return "Hello"; };
- Arrow Functions (ES6)
const greet = () => "Hello";
- Hoisting: Function declarations are hoisted, expressions are not.
- DOM Selectors: `getElementById`, `querySelector`
- DOM Manipulation: `innerText`, `innerHTML`, `classList`, `style`
- Event Listeners: `addEventListener()
- Event Propagation: Bubbling, Capturing, Delegation
document.getElementById("btn").addEventListener("click", () => {
alert("Clicked!");
});
- `window`, `location`, `navigator`, `screen`, `history`
console.log(window.innerHeight);
console.log(location.href);
- Patterns: Literals, Ranges, Groups
- Methods: `test()`, `exec()`, `match()`, `replace()`
let pattern = /[A-Z]/g;
let result = "Ayush".match(pattern); // ['A']
- Object Literals, Constructor Functions
- Prototypes and Prototypal Inheritance
- Classes (ES6)
- Encapsulation, Inheritance, Polymorphism
class Person {
constructor(name) {
this.name = name;
}
greet() {
return `Hi ${this.name}`;
}
}
- AJAX using `XMLHttpRequest`
- Fetch API
- Promises and `async/await`
- Error Handling: `try/catch`, `.catch()`, `finally`
let xhr = new XMLHttpRequest();
xhr.open("GET", "data.json", true);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
fetch("data.json")
.then(res => res.json())
.then(data => console.log(data));
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
$(document).ready(function() {
$("#btn").click(function() {
$("p").text("Button clicked");
});
});
- Uses `$()` as a shorthand for document selection
- Event HandlingHandling
- AJAX
- Cross-browser compatibility
- DOM Selection, traversal, manipulation, animations, and AJAX
- `let`, `const`, Arrow Functions
- Template Literals
- Destructuring
- Spread and Rest Operators
- Modules: `import/export`
- Promises, async/await
- Classes and Inheritance
const user = { name: "Ayush", age: 23 };
const { name, age } = user;
const sum = (...nums) => nums.reduce((a, b) => a + b, 0);
- Event Loop
- Callbacks, Promises, async/await
- Error Handling with async code
- `this` Keyword
- `call`, `apply`, `bind`
- Closures and IIFE
- Higher-Order Functions
- Singleton
- Observer
- Module
- Factory
- Pure Functions
- Immutability
- Higher-Order Functions
- Function Composition
- `"use strict"`
- Linting
- Debugging Tools
- Testing with Frameworks
- npm, Babel, Parcel
- Webpack, Linters, Prettier
- Testing Frameworks (Jest, Mocha)
- Modular Code Organization
- Dependency Management
- Folder Structure Best Practices
- Local Storage & Session Storage
- IndexedDB
- Web Workers & Service Workers
- Profiling with DevTools
- Reducing DOM Manipulations
- Debouncing and Throttling
- Lazy Loading and Efficient Selectors
- Namaste JavaScript - YT playlist
- Telusko - YT playlist
- JavaScript - Basics to Advanced step by step [2022] - Udemy Cource
- Sheryians Coding School - YT JavaScript Core
- From Udemy Cource :
- JavaScript - Basics to Advanced ES6 step by step [2022] : Issue date - December 2022
Credential ID - UC-0382127f-523a-4c7f-b966-ba33426153be
Certificate
- JavaScript - Basics to Advanced ES6 step by step [2022] : Issue date - December 2022