From the course: Learning Functional Programming with JavaScript ES6+

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Separation of data and functions

Separation of data and functions - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript ES6+

Start my 1-month free trial

Separation of data and functions

- [Instructor] The second main concept of functional programming is the separation of data and functions. This is a case where functional programming is directly in contrast with object-oriented programming, where data and functions are almost always grouped together. Let's see what this looks like. First of all for our purposes, let's discuss what data and functions actually are. For our purposes, data might be any values that a program contains, people's names, addresses, and social security numbers in a payroll program, the models, years, and colors of cars on a used car website, the positions, health levels and weapons of characters in a video game, anything. All of this is data. In object-oriented programming, this data is usually wrapped up inside objects as member variables, and the only way we can access it is using an object's methods. In functional programming on the other hand, this data is represented by simple arrays and hashes, or in this case, JavaScript objects. And a…

Contents