Function.prototype.prototype
Holds the object that becomes the prototype of every instance the function constructs with new.
func.prototype- Added in JavaScript ECMAScript 1 (1997)
Return value
Object | undefinedThe object used as the new instance's prototype when the function is called with new; undefined on functions that do not have the property.
Changelog
- PHP ECMAScript 2015Arrow functions, shorthand and concise object/class methods, and async functions were defined without a prototype property, making them permanently non-constructable.
- PHP ECMAScript 2015Bound functions have no own prototype property but remain constructable when the target function is; instanceof still resolves through the target.
- PHP ECMAScript 2015Generator and async generator functions have a prototype property, but it is used for the returned iterator — they still throw if called with new.
A function's prototype property is the object that new installs as the prototype of each instance it creates. It is writable and non-enumerable but not configurable, and by default holds a fresh object with a constructor back-reference.
When to reach for it
- Reading the shared method table of a constructor or class —
Array.prototype.map,Object.getOwnPropertyNames(C.prototype). - Borrowing built-in methods for array-likes via
Array.prototype.slice.call(...). - Testing whether something is constructable:
Object.hasOwn(fn, "prototype")is a cheap first check.
What trips people up
The biggest confusion is fn.prototype versus Object.getPrototypeOf(fn). They are different objects: the first is what instances will inherit from, the second is what the function itself inherits from (Function.prototype). fn.prototype === Object.getPrototypeOf(fn) is false for ordinary functions.
Not every function has one. Arrow functions, shorthand methods, async functions and bound functions have no own prototype, and assigning one afterwards does not make them constructable — new still throws a TypeError.
Finally, replacing fn.prototype wholesale orphans every object already created: existing instances keep pointing at the old object and stop passing instanceof.
Example
When to use it
- Inspect which methods a constructor shares with all its instances
- Borrow Array.prototype methods to work on an array-like object
- Check whether a value is usable as a constructor before calling new on it
- Add a method to every instance of a legacy constructor function
Frequently asked questions
What is the difference between prototype and __proto__?
prototype is a property on constructor functions holding the object their future instances will inherit from; __proto__ (properly Object.getPrototypeOf) is the link an object already has to its own prototype. Only functions have prototype; every object has a [[Prototype]].
Why does my arrow function throw "is not a constructor"?
Arrow functions are defined without a prototype property and are permanently non-constructable, so new on one throws a TypeError. Manually assigning a prototype does not help — use a function declaration or a class if you need new.
Do class methods live on the prototype?
Yes — instance methods of a class go on Class.prototype and are shared by every instance, while class fields and anything assigned to this in the constructor are per-instance own properties. Static methods live on the class itself, not its prototype.
More examples
Shared methods, and what happens if you replace the object
p is linked to the original prototype object at construction time, so it keeps the old toString after the swap. instanceof compares Point.prototype against p's chain, and since Point.prototype now points somewhere else the check flips to false.
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.toString = function () { return `(${this.x}, ${this.y})`; };
const p = new Point(1, 2);
console.log(String(p));
console.log(Object.getPrototypeOf(p) === Point.prototype, p instanceof Point);
Point.prototype = { toString() { return "replaced"; } };
console.log(String(p), p instanceof Point);prototype is not the function's own prototype
The three booleans separate the two concepts: F.prototype is for F's instances, Object.getPrototypeOf(F) is Function.prototype because F is itself a function object. Generators show that having a prototype property does not imply constructability — theirs is used for the iterator they return.
function F() {}
console.log(F.prototype === Object.getPrototypeOf(F)); // false
console.log(Object.getPrototypeOf(F) === Function.prototype); // true
console.log(Object.getPrototypeOf(new F()) === F.prototype); // true
function* gen() {}
console.log("generator has prototype:", Object.hasOwn(gen, "prototype"));
try { new gen(); } catch (e) { console.log("generator + new:", e.constructor.name); }
Discussion