Understanding Prototype Inheritance in JavaScript

🚀 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

  • text

What are the advantages of it over let getObjVal = { city:"kolkata", ...obj }

Like
Reply

Ahh this is so commonly called as meta methods & metaclass in Lua. Now, these concepts have been introduced in JavaScript as well!

See more comments

To view or add a comment, sign in

Explore content categories