From harness-claude
Shares properties and methods across JavaScript instances via prototype chain. Use for memory-efficient objects with many shared methods, avoiding per-instance duplication.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Share properties and methods across instances via the prototype chain
Implements JS Constructor Pattern using ES6 classes for object instances with validation, private fields, shared methods, and instanceof checks. Use when creating multiple similar objects with init logic.
Generates Prototype pattern implementations for PHP 8.4: deep/shallow clones, clone customization, prototype registries, immutable object duplication.
Explains 33+ essential JavaScript concepts like primitives, type coercion, scope, closures for debugging quirks, teaching fundamentals, reviewing best practices, and understanding language behavior.
Share bugs, ideas, or general feedback.
Share properties and methods across instances via the prototype chain
.prototype object — not inside the constructor function.this inside the constructor.Object.create(proto) for explicit prototype assignment without a constructor.function Dog(name) {
this.name = name;
}
Dog.prototype.bark = function () {
return `${this.name} says woof!`;
};
const d1 = new Dog('Rex');
const d2 = new Dog('Spot');
// Both share the same bark function in memory
console.log(d1.bark === d2.bark); // true
class syntax — it uses the prototype chain under the hood but is more readable.hasOwnProperty() or Object.hasOwn() to distinguish own vs inherited properties.Every JavaScript object has an internal [[Prototype]] link. When you access a property, the engine walks the chain: own properties first, then the prototype, then the prototype's prototype, until null. This is the prototype chain.
Trade-offs:
class syntax is clearer than manual .prototype manipulationWhen NOT to use:
#field) insteadhttps://patterns.dev/javascript/prototype-pattern