In JavaScript, prototypal inheritance is a mechanism through which objects can inherit properties and behavior from other objects. Every object in JavaScript has an internal property called [[Prototype]], which can be accessed using the `Object.getPrototypeOf()` or `__proto__` (deprecated) methods. The [[Prototype]] property refers to another object, often called the prototype object. When a property or method is accessed on an object, and the object itself does not have that property, JavaScript automatically looks up the prototype chain to find the property on the prototype object. Here's an example to illustrate prototypal inheritance:

// Parent object constructor
function Person(name) { = name;

// Adding a method to the prototype of Person
Person.prototype.greet = function() {
  console.log("Hello, my name is " +;

// Creating a new object using the Person constructor
var john = new Person("John");

// Accessing the greet method inherited from the prototype
john.greet(); // Output: Hello, my name is John

In the example above, the `Person` function serves as a constructor for creating person objects. The `Person` constructor has a property `name`, which is assigned when a new object is created using `new Person("John")`. Additionally, we add a `greet` method to the `Person.prototype`. This means that all objects created using the `Person` constructor will inherit the `greet` method. When `john.greet()` is called, JavaScript looks for the `greet` method on the `john` object. Since it's not found, JavaScript follows the prototype chain and finds the `greet` method on the `Person.prototype`. The method is then invoked with `this` referring to the `john` object. Prototypal inheritance allows objects to inherit and share properties and methods from their prototypes. If a property or method is not found on the object itself, JavaScript continues the lookup in the prototype chain until it reaches the end (usually `Object.prototype`) or finds the property/method. This inheritance mechanism provides a flexible and efficient way to reuse code and build complex object hierarchies in JavaScript.