Closures: ========= Closure is function that remembers the variables from its lexical scope even when the function is executed outside that corresponding scope. function outerFunction(outerVariable) { function innerFunction(innerVariable){ console.log("Outer Function Parameter = ",outerVariable); console.log("Inner Function Parameter = ",innerVariable); } // console.log(innerVariable); return innerFunction; } let newFunction = outerFunction("Hello"); newFunction("Good Morning"); function createCounter(){ let count = 0; return{ increment:function(){ count++; console.log(`Count After the increment = ${count}`); }, decrement:function(){ count--; console.log(`Count After the decrement = ${count}`); }, reset:function(){ count = 0; console.log(`The Count Value after the reset = ${count}`); }, getCount:function(){ console.log(`The Current Count = ${count}`); return count; }, } } const counter = createCounter(); // 0 counter.increment(); // 1 counter.increment(); // 2 counter.getCount(); // 2 counter.decrement(); counter.getCount(); counter.reset(); ========================================================= OOPs (Object Oriented Programming System) ========================================= ==> High level Programming Languages: 1) Functional 2) Object Based 3) Object Oriented Object Oriented Programming: 1) Class 2) Object 3) Method 4) Constructor OOP Principles: 1) Encapsulation 2) Inheritance 3) Polymorphism 4) Abstraction Project: Task Management: =========================== // class ==> blueprint ==> collection of attributes and methods ==> keyword: class class Task{ // defining a constructor // to initialize the data members // special method constructor(title, descript, dueDate){ this.title = title; this.descript = descript; this.deuDate = dueDate; this.status = "Pending"; // default value } markAsCompleted(){ this.status = "Completed"; } updateDetails(title,descript,dueDate){ this.title = title || this.title; this.descript = descript || this.descript; this.dueDate = dueDate || this.dueDate; } getDetails(){ return{ title:this.title, description:this.descript, status:this.status, dueDate:this.dueDate }; } } class TaskManager{ constructor(){ this.tasks = []; } addTask(task){ this.tasks.push(task); } removeTask(title){ this.tasks = this.tasks.filter(task => task.title !== title); } updateTask(title,newDetails){ const task = this.tasks.find(task => task.title === title); if(task){ task.updateDetails(newDetails.title,newDetails.descript,newDetails.dueDate); } } listTask(){ return this.tasks.map(task => task.getDetails()); } } const tm = new TaskManager(); const t1 = new Task('Finish Project','Complete the Project by the end of the month','2025-01-31'); const t2 = new Task('Reading Book','Read the JavaScript Tutorial','2025-02-07'); tm.addTask(t1); tm.addTask(t2); console.log(tm.listTask());