🚀 Sharing a Quick JS Concept: Prototype Inheritance Just revisited how prototype inheritance works in JavaScript. When one object inherits properties from another using __proto__, it allows property lookup through the prototype chain. let obj = { name: "soumen", age: 25 }; let getObjVal = { city: "kolkata", __proto__: obj }; console.log(getObjVal.name); // soumen Even though getObjVal doesn’t have name, it finds it in obj through its prototype. 💡 #JavaScript #FrontendDevelopment #WebDevelopment #LearningEveryday #UIDeveloper
Ahh this is so commonly called as meta methods & metaclass in Lua. Now, these concepts have been introduced in JavaScript as well!
What are the advantages of it over let getObjVal = { city:"kolkata", ...obj }