Get the App
SLTechnology News&Howtos  ›  Development  › 

Introduction to the characteristics of JS facing object

Shulou Source: shulou.com Published: 2022-06-03 14:55:12 10月03日 Update

This article mainly explains "the introduction of the characteristics of JS facing the object". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the introduction of the characteristics of JS facing objects".

Object-oriented features: encapsulation, inheritance, polymorphism

Packaging: it is packaging.

A value is stored in a variable-- encapsulation

A piece of repetitive code is put in a function-- encapsulation.

A series of attributes are placed in an object-- encapsulation

Some functions (methods) with similar functions are placed in an object-- encapsulation

Many similar objects are placed in a js file-encapsulation

Inheritance:

First of all, inheritance is a kind of relationship, the relationship between class and class, there is no class in JS, but you can simulate the class by constructor, and then realize inheritance through prototype.

Inheritance is also for data sharing, and inheritance in js is also for data sharing.

One of the prototype functions: data sharing, saving memory space

The second part of the prototype function: in order to realize inheritance

Inheritance is a relationship:

Relationship between parent class level and subclass level

Polymorphism:

An object has different behaviors, or the same behavior produces different results for different objects. If you want to have polymorphism, you must first have inheritance. Polymorphism can be simulated in js, but it will not be used or modeled.

Conclusion: the above is all about advanced JS-- inheritance, please pay attention to more.

Thank you for your reading, the above is the content of "introduction to the characteristics of JS facing objects". After the study of this article, I believe you have a deeper understanding of the introduction of the characteristics of JS facing objects, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Objects encapsulation features polymorphism content differences functions prototypes that is data learning roles more levels behaviors advanced between code memory functions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info MariaDB Redmi Docker