Mastering JavaScript Prototypes & Chaining: Day 6 Challenge

🚀 #Day6 Challenge — Mastering JavaScript Prototypes & Prototype Chaining. Today’s deep dive was all about one of the core pillars of JavaScript — Prototypes and Prototype Chaining 🧠 I explored how every JavaScript object has an internal link to another object called its prototype, and how properties & methods are inherited through the prototype chain. Here’s what I learned today 👇 ✅ How functions in JS automatically get a .prototype object ✅ How object instances share methods using prototypes (memory-efficient inheritance) ✅ What happens when JS looks for a property — and how it walks up the chain (Prototype Lookup) ✅ The difference between __proto__ and .prototype ✅ How to manually create inheritance using Object.create() ✅ Real-world examples like Library System, E-commerce Product System, and Employee Management System built using prototypes and chaining // Creating a Employee Management System with raise using constructor function and prototype methods function Employee(name, salary, department) {     this.name = name;     this.salary = salary;     this.department = department; } Employee.prototype.getDetails = function() {     console.log(`// Name: ${this.name} | Department: ${this.department} | Salary: ₹${this.salary}`); }; Employee.prototype.giveRaise = function(percent){     this.salary += this.salary*percent/100;     console.log(`New salary for ${this.name} is ₹${this.salary}`); }; const emp1 = new Employee('Rahul',5000,'IT'); const emp2 = new Employee('Rahul',5000,'IT'); emp2.getDetails(); emp2.giveRaise(10); 💡 Key Takeaway: Prototypes are the backbone of JavaScript’s inheritance — understanding them gives true control over how objects behave and interact. 📘 Next up: Moving toward “Classes & Inheritance in ES6” — where I’ll connect prototypes with modern class syntax for cleaner, scalable code. #JavaScript #Prototypes #PrototypeChaining #Day6Challenge #WebDevelopment #LearnInPublic #FrontendDeveloper #CodingJourney #AsyncJavaScript #Closures #Scopes #LexicalEnvironment #DeveloperGrowth #100DaysOfCode #BuildInPublic

  • diagram, schematic

To view or add a comment, sign in

Explore content categories