Книга: Functional Programming in JavaScript
Назад: JavaScript – the multi-paradigm language
Дальше: Inheritance

JavaScript's object-oriented implementation – using prototypes

JavaScript is a class-less language. That's not to mean it is less fashionable or more blue-collar than other computer languages; class-less means it doesn't have a class structure in the same way that object-oriented languages do. Instead, it uses prototypes for inheritance.

Although this may be baffling to programmers with backgrounds in C++ and Java, prototype-based inheritance can be much more expressive than traditional inheritance. The following is a brief comparison between the differences between C++ and JavaScript:

C++

JavaScript

Strongly typed

Loosely typed

Static

Dynamic

Class-based

Prototype-based

Classes

Functions

Constructors

Functions

Methods

Functions

Назад: JavaScript – the multi-paradigm language
Дальше: Inheritance

bsn
thank
Vesa Karvonen
I hope you don't mind, but I’d like to point you and your readers to my high-performance optics library for JavaScript that is in production use in multiple projects, has comprehensive support for partial optics and interactive documentation: https://calmm-js.github.io/partial.lenses/ (this takes a moment to load — be patient!)