- Variables:
let,const,var- Example:
const name = "Hitesh";
- Example:
- Data Types: String, Number, Boolean, Object, Array, Null, Undefined, Symbol
- Operators:
+,-,*,/,===,!==,&&,||,++,--
- Conditionals:
if,else,else if,switch - Loops:
for,while,do-while,for...of,for...in
- Function Declaration:
function greet() { ... } - Function Expression:
const greet = function() { ... }; - Arrow Functions:
const greet = () => { ... }; - Default Parameters:
function greet(name = "Guest") { ... } - Higher-Order Functions: Passing functions as arguments (e.g.,
map,filter,reduce)
- Object Literals:
const user = { name: "Hitesh", age: 25, greet: function() { console.log("Hello!"); }, };
- Constructors:
function User(name, age) { this.name = name; this.age = age; }
- Prototype Inheritance:
User.prototype.sayHi = function() { console.log(`Hi, I am ${this.name}`); };
- Depends on the context (e.g., global, object, function, arrow function)
- In
call(),apply(),bind(), we explicitly setthis.
- Common Methods:
push(),pop(),shift(),unshift()slice(),splice()- Iterators:
forEach(),map(),filter(),reduce() - Find & Search:
find(),findIndex(),indexOf()
- Promises:
const promise = new Promise((resolve, reject) => { resolve("Success!"); });
- Chaining:
.then(),.catch() - Async/Await:
async function fetchData() { const data = await fetch(url); return data.json(); }
- Selecting Elements:
document.querySelector(),getElementById() - Modifying Elements:
.innerHTML,.style,.classList - Events:
addEventListener(), Event Delegation
- Template Literals:
`Hello, ${name}!` - Destructuring:
const { name, age } = user; const [first, second] = array;
- Spread & Rest:
...const combined = [...arr1, ...arr2];
- Modules:
import,export - Default Parameters:
function greet(name = "Guest") { ... }
- Try-Catch Block:
try { riskyCode(); } catch (error) { console.error(error); }
- Closures: Functions that remember their lexical scope.
function outer() { let counter = 0; return function inner() { counter++; console.log(counter); }; }
- Event Loop: Understanding how JavaScript handles asynchronous tasks using the Call Stack, Web APIs, and Event Queue.
- Hoisting: Variable and function declarations are moved to the top of the scope.
- Master advanced concepts like Modules, Web APIs, and Design Patterns. 🚀