From the course: Learning Functional Programming with JavaScript ES6+
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Converting object-oriented to functional code - JavaScript Tutorial
From the course: Learning Functional Programming with JavaScript ES6+
Converting object-oriented to functional code
- If you're coming from an object-oriented background, it may seem strange to you that functional programming places an emphasis on keeping data and functions separate. Since one of the central concepts of object-oriented programming is that we put data and the functions related to that data together in objects. To understand why it makes sense to keep data and functions separate and functional programming, it might be helpful to think about why we keep them together in object-oriented programming in the first place. The main reason that it's useful to keep data and functions together in the same object is that this allows us to interact with the member variables of an object without touching them directly. What's wrong with touching variables directly? Well, if we give programmers direct access to variables, they can, and in my experience, will change them in ways that they're not supposed to. Consider the simple case of a person object with publicly accessible properties, first…
Contents
-
-
-
(Locked)
The goal of functional programming3m 38s
-
(Locked)
Declarative vs. imperative programming2m 46s
-
(Locked)
Immutability4m 18s
-
(Locked)
Separation of data and functions1m 47s
-
(Locked)
Converting object-oriented to functional code3m 29s
-
(Locked)
First-class functions2m 33s
-
(Locked)
Ensuring immutability with ESLint3m 14s
-
(Locked)
Installing and setting up ESLint1m 14s
-
(Locked)
Ensuring immutability: Finalize ESLint2m 27s
-
(Locked)
-
-
-
-
-