# JavaScript's Prototypal Inheritance

Prototypal inheritance is a feature in JavaScript that allows objects to inherit properties and methods from other objects. Here’s an example:

const parent = {
greet() {
console.log('Hello from parent!');
}
};
const child = Object.create(parent);
child.greet(); // Hello from parent!

Prototypal inheritance is a flexible way to share behavior between objects without using classes.

Testing Prototypal Inheritance
node -e "const parent = { greet() { console.log('Hello from parent!'); } }; const child = Object.create(parent); child.greet();"
My avatar

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.


More Posts