You can see

Basic knowledge

The difficulties in

Must be back

right

JS Light of the world

There’s more to learn

JS Learning Plan

knowledge

  • The basic concept

Memory, variables, data types, objects

  • Control statements

The if… else…

The for…

  • object

Prototype, prototype chain

Object classification

New A new object

The constructor

Implicit and explicit passing of this

The difficulties in

  • JS Three Mountains

The prototype

this

AJAX

  • We’ve already met the first two

I still don’t get it

Don’t get it

Do you understand that it’s still three mountains

The front threshold is right here

So what?

It’s simple. Learn and understand

Must be back

First important knowledge: JS formula

Object._ _proto_ _ === its constructor. Prototype

JS unique formula, if not set formula

Second important knowledge: the root axiom

Object. Prototype is the (direct or indirect) prototype of all objects

Add a direct or indirect, the axiom is defined

Third important knowledge: axioms of functions

All functions are constructed by Function

__proto__ === function.prototype

Any Function has Object/Array/Function

JS formula, root axiom, function axiom

Based on these three knowledge and basic knowledge, the JS world can be derived

right

The wrong idea that your brain might have

  • The prototype of the XXX

Such as

The prototype of the {name: “frank”}

The prototype of the [1, 2, 3]

The prototype of the Object

  • Interpretation of the

The prototype of Object is Object. Proto: Yes

Object. Prototype: False

  • Where is wrong

“Prototype” is equivalent to “.__proto__”

The Chinese word “prototype” does not distinguish __proto__ from prototype

So we can only agree that the stereotype defaults to __proto__

Only __proto__ is exactly equal to the prototype of a function

The idea that your brain might be wrong

  • I think you’re contradicting yourself

The [1,2,3] prototype is array.prototype

Object. Prototype is the prototype of all objects

Object. Prototype [1,2,3

  • Where is wrong

There are two types of prototypes: direct and indirect

For ordinary objects, Object.prototype is a direct prototype

Object. Prototype is an indirect prototype for arrays and functions

Your brain may be wrong idea number three

  • Object. Prototype is not the root Object

  • Reason (false)

Object. Prototype is the prototype of all objects

Object is constructed by Function

So Function constructs Object.prototype

Inference: Function is the source of all things.

  • Where is wrong

Functio constructs only the Object. Prototype address, not the Object

Prototype differs from object. prototype

Object never contains another object, only the address of another object

Next we need to clarify the order in which the JS world is built

Object. Prototype Specifies the address of the Object

JS Light of the world

Construct order of JS world (must understand, can draw)

  1. Create a root object #101(toString) that has no name

  2. Create a prototype of the function #208(call /apply) with a prototype __p of #101

  3. Create an array with a prototype #404(push/pop) and a prototype __p of #101

  4. Create Function #342 with prototype __p as #208

  5. Use Function. Prototype to store the Function’s prototype, equal to #208

  6. Function __proto__ and prototype are both #208

  7. Create Object with Function

  8. Object. Prototype Stores the prototype of an Object equal to #101

  9. Create an Array with Function

  10. Array.prototype Stores the Array prototype, equal to #404

  11. Creating a window object

  12. Name the functions in 7 and 9 using the window’s ‘Object’ and ‘Array’ properties

  13. Remember that when JS creates an object, it does not give the object a name

  • The order in which the JS world is constructed (continued)
  1. Create obj1 with new Object()

  2. New sets obj1’s prototype __p to Object.prototype, which is #101

  3. Create arR1 with new Array()

  4. New sets arr1’s prototype __p to array. prototype, which is #404

  5. Create f1 with new Function

  6. New sets f1’s prototype __p to function. prototype (#208)

  • The order in which the JS world is constructed (continued)
  1. Define the constructor Person, and add an attribute to this

  2. Person automatically creates the Prototype attribute and the corresponding object #502

  3. Add attributes to Person.prototype #502

  4. Create object p with new Person()

  5. New sets p’s prototype __p to #502

graphic

conclusion

  • The constructor

It’s used to construct objects

The prototype of the object is pre-stored, and the prototype of the prototype is the root

New points the object’s __p to the prototype

  • object

All objects refer directly or indirectly to the root object

If the object wants to be categorized, a link is added to the prototype chain

We can add this ring to the construct object

  • thinking

What if, after adding one, you want to add another

We’ll talk about that in inheritance

What else I haven’t learned

  • Error handling try… catch…

Read the netpath textbook (or not)

Have a deep understanding in the project

  • Math/Date/Re/JSON

You can read the textbook first (or not)

Have a deep understanding in the project

  • I think

If you do it now, you’ll forget it tomorrow

Writing is better than listening, and doing is better than writing

JS Learning Plan

  • The first stage

Understand JS syntax, features, objects, arrays, functions, etc

  • The second stage

Knowledge of AJAX, design patterns, encapsulation, object-oriented, MVC

  • The third stage

Vue/React Family bucket

All right, ready to work