JavaScript Deep Notes
1. Variables and Data Types
JavaScript has three types of variable declarations: var, let, and const.
- var: function-scoped, hoisted, can be redeclared.
- let: block-scoped, not hoisted, cannot be redeclared in same scope.
- const: block-scoped, not hoisted, must be initialized during declaration.
Data Types:
- Primitive: string, number, boolean, null, undefined, symbol, bigint
- Non-Primitive: arrays, objects, functions
JavaScript Deep Notes
2. Operators and Control Flow
Operators:
- Arithmetic: +, -, *, /, %, **
- Comparison: ==, ===, !=, !==, >, <, >=, <=
- Logical: &&, ||, !
- Ternary: condition ? expr1 : expr2
Control Flow:
- if, else if, else
- switch
- for, while, do...while
- break, continue
JavaScript Deep Notes
3. Functions and Scope
Function Types:
- Function Declaration
- Function Expression
- Arrow Functions (ES6)
Scope:
- Global Scope
- Function Scope
- Block Scope (let, const)
Hoisting: Function declarations and var are hoisted to top of scope.
Closures: Function remembers the variables from its lexical scope even after outer function has returned.
JavaScript Deep Notes
4. Arrays and Objects
Array Methods:
- push, pop, shift, unshift, splice, slice
- map, filter, reduce, forEach, find, some, every
Object Methods:
- [Link](), [Link](), [Link]()
- Destructuring: const {name, age} = obj;
JavaScript Deep Notes
5. DOM Manipulation
- [Link]("id")
- [Link](".class")
- [Link] / textContent
- [Link]() / getAttribute()
- [Link] = "value"
- createElement, appendChild, removeChild
JavaScript Deep Notes
6. Events and Listeners
- onclick, onmouseover, onkeydown
- addEventListener("click", function)
- Event Object: [Link], [Link], [Link]()
- Event bubbling and capturing
JavaScript Deep Notes
7. Advanced JS Concepts
- this keyword: refers to context object
- call(), apply(), bind()
- Prototypes and inheritance
- Hoisting: var and function declarations are hoisted
- Strict Mode: 'use strict'
JavaScript Deep Notes
8. ES6+ Features
- let, const
- Arrow Functions
- Template Literals: `Hello ${name}`
- Spread & Rest: [...arr], (...args)
- Destructuring: const [a, b] = arr;
- Promises, Async/Await
JavaScript Deep Notes
9. Error Handling
- try...catch
- throw new Error("message")
- finally block always executes
JavaScript Deep Notes
10. JSON and APIs
- [Link](obj): convert object to JSON string
- [Link](json): convert JSON string to object
- fetch(url).then(res => [Link]()).then(data => [Link](data))