jskatas.org Continuously Learn JavaScript. Your Way.

function API: function.prototype

The prototype property of a function is an object that is used to implement inheritance and shared properties.

The prototype property - the place to add shared functionality

WHEN defining the prototype on a function THEN the instance of that function inherits these properties
const fn = function() {} fn.prototype = { solution: 42, }; const obj = new fn(); assert.equal(obj.solution, 42);

Links

The very first version of the spec defines this property already, the ES1 spec, see section 15.3.5.2 (PDF 732kB).

Related Katas

function API

Arrow functions

Async Function

Difficulty Level

BEGINNER

Stats

1 tests to solve