1. Three most important pieces of knowledge:

1. JS formula

  • Object.__proto__=== its constructor. Prototype(JS unique formula, if not set formula)

2. The root cause

  • Object.prototypeIs the (direct or indirect) archetype of all objects.

3. Function axioms

  • All functions are defined byFuncitionStructure of the
  • Any function __proto__=== funcition.prototyp
  • Any function has Object/Array/Funciton

Second, JS world

The order in which the JS world is constructed

1. Create root object #101

  • There are some properties in there, liketoString.valueOf
  • The root object has no name
  • The prototype is defined asnull, i.e.,__proto__ : null

2. The root object has no name to create the prototype of the function #208

  • There are some properties in there, likecall,apply
  • I’m created from a root object, so I’m modeled after a root object# 101, i.e.,__proto__ : #101

3. Create an array prototype #404

  • There are some properties in there, likepush,pop
  • I’m created from a root object, so I’m modeled after a root object# 101, i.e.,__proto__ : #101

Create Function #342 and prototype __p = #208

  • withFunction.prototypeThe prototype of the storage function is equal to# 208
  • Found at this timeFunction__proto__prototypeAre all# 208

5. Use Function to create Object

  • withObject.prototypeThe prototype of the stored object is equal to# 101

6. Create an Array with Function

  • withArray.prototypeThe prototype of the storage array is equal to# 404

7. Create the window object

  • withwindow'Object' 'Array'Property names the functions in 5 and 6
  • Remember that when JS creates an object, it does not give the object a name

The construction order of the JS world (Continuation 1)

  • withnew Object()createobj1
  • newwillobj1The prototype of the__pSet toObject.prototype, that is,# 101
  • withnew Array() to create aarr1
  • newwillarr1The prototype of the__pSet toArray.prototype, that is,# 404
  • withnew Functioncreatef1
  • newwillf1 the prototype of the__pSet toFunction.prototypE, that’s just e# 208

The construction order of the JS world (Continuation 2)

  • Define your own constructorsPersonThe function givesthisAdd attribute
  • PersoN Automatic CreationprototypeProperty and corresponding object# 502
  • inPerson.prototype #502Add attributes to it
  • withnew Person()Create an objectp
  • newwillpThe prototype of the__pSet to# 502

graphic