## Defined

To clear up the confusion of prototype in this which really confused me for months before. All stuff work around with this article. If you still don’t know the answer, check the link and find @daremkd‘s answer.

## Main()

Keys: __proto__, prototype, prototype chain, this in prototype several examples

### an important part

a1.__proto__ property is assigned to point at the same thing as A.prototype points to (another empty object {} )

### where to find __proto__ and prototype?

__proto__ in every Object included function.
prototype only create when function created.

### Why __proto__?

-- Delegation | prototype chain (could refer prototype design pattern)

Attention: checkout this in this example, it will follow the Objects’ __proto__ and point it, which means it’s dynamic.

### Why prototype?

-- act like a member of class-based Languagers :)

a1 and a2 both act like inherit the say function, BUT the result a1.say == a2.say is false.
The truth is every new instance created, say function will be create again and again, that will really drag system slow and fill up the stack / memory.

Good practice:

• b1 stand for

• and b2

Attention: the problem of this in prototype seems to be solved in b1 and b2 results, this is dynamic.
and the mechanism is a.__proto__ = A.prototype.

### new mind map

This image explained the relationship among function, Function and Object. Apparently, Object is the highest Constructor.

new function() and new Function()

eval and Function
You should avoid eval() and new Function().

demo:

new Function() usage:
Inner variables scope is Global

new Function(param1, param2[, …], functionBody);