Object-oriented programming

  • What is object orientation? The js concept is – a collection of non-permissible attributes (base values, objects, functions)

1. Understand the object

What are the types of attributes?

1.1 Data Attributes

  • A simple summary of data attributes is:

** The writable, freely modifiable and enumerable works without any additional control

  • Modify object.defineProperty (obj,argument,{})
  • Modify configuration properties for the first time false Cannot be modified later

1.2 Accessor Properties

  • Enumerable, read, set, and works without any additional control system.

  • Reads the properties Object. GetOwnPropertyDescriptor (obj, argument)


2. Create an object

  • Disadvantages of factory mode: No object identification

  • Constructor pattern

    1. Create a new object 2. Assign the constructor’s scope to the new object 3. Add attributes to an object. 4. Return a new object

  • A constructor is also a function (special in that you can construct a new object)

Disadvantages: Additional internal function methods need to be defined **

  • The prototype pattern

The function has its own protoType which is a pointer to an object containing all properties and method instance information added to the protoType to ensure that all objects are shared