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

Chapter 7. Functional and Object-oriented Programming in JavaScript

You will often hear that JavaScript is a blank language, where blank is either object-oriented, functional, or general-purpose. This book has focused on JavaScript as a functional language and has gone to great lengths to prove that it is. But the truth is that JavaScript is a general-purpose language, meaning it's fully capable of multiple programming styles. Like Python and F#, JavaScript is multi-paradigm. But unlike those languages, JavaScript's OOP side is prototype-based while most other general-purpose languages are class-based.

In this final chapter, we will relate both functional and object-oriented programming to JavaScript, and see how the two paradigms can complement each other and coexist side-by-side. In this chapter the following topics will be covered:

  • How can JavaScript be both functional and OOP?
  • JavaScript's OOP – using prototypes
  • How to mix functional and OOP in JavaScript
  • Functional inheritance
  • Functional mixins

Better code is the goal. Functional and object-oriented programming are just means to this end.

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

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!)