课程: Learning Functional Programming with JavaScript ES6+ (2019)

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Separation of data and functions

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…

内容