Note: All internal properties or entities are written using [[...]] notation.
— the internal [[Prototype]] attribute of every object
All objects have this internal [[Prototype]] attribute. This is the same __proto__ property.
in progress
— the prototype property of functions
Imagine an internal [[Function]] constructor which is used to create a function object.
/*************************
function [[Function]](name) {
this.length = 0
this.name = name || 'anonymous'
this.prototype = { constructor: this }
}
**************************/
So when a new function is created such as
internally, it runs
/*********************
f = new [[Function]]('f')
*********************/
which creates an instance of [[Function]] object which is of function type with the name as 'f' i.e.
typeof f === 'function' // true
f.name // 'f'
Now let us see the properties of the newly created function f object
Object.getOwnPropertyNames( f ) // ['length', 'name', 'prototype']
NOTE: if you see additional properties such as arguments and caller, then, it is because the function might be created using the new Function constructor (and NOT the internal [[Function]] constructor directly).
As you can see, there is a length, name and prototype properties. These properties are pretty popular 😉
Let us have a look at their values.
console.log(f.name) // "f"
console.log(f.length) //0
console.log(f.prototype) // { constructor: f }
Internal [[Prototype]] attribute of every object and prototype property of functions are two distinct entities. Do not confuse between them.