What is the default prototype for custom function in JavaScript?

The prototype property of function objects is automatically created, is simply an empty object with the {DontEnum} and {DontDelete} property attributes, you can see how function objects are created in the specification:

  • 13.2 Creating Function Objects

Pay attention to the steps 9, 10 and 11:

9) Create a new object as would be constructed by the expression new Object().

10) Set the constructor property of Result(9) to F. This property is given attributes { DontEnum }.

11) Set the prototype property of F to Result(9). This property is given attributes as specified in 15.3.5.2.

You can see that this is true by:

function f(){
  //...
}

f.hasOwnProperty('prototype'); // true, property exist on f

f.propertyIsEnumerable('prototype'); // false, because the { DontEnum } attribute

delete f.prototype; // false, because the { DontDelete } attribute

Here is a link describing object inheritance:

http://javascript.crockford.com/prototypal.html

http://www.mollypages.org/misc/js.mp alt text
(source: mollypages.org)