JavaScript Interview Question: Explain OOP and FP

What is Object-Oriented Programming? What is Functional Programming?Photo by La-Rel Easter on UnsplashObject-Oriented Programming(OOP) and Functional Programming (FP) are programming paradigms that allow us to organize our code in a specific manner.But…


This content originally appeared on Bits and Pieces - Medium and was authored by Aman

What is Object-Oriented Programming? What is Functional Programming?

Photo by La-Rel Easter on Unsplash

Object-Oriented Programming(OOP) and Functional Programming (FP) are programming paradigms that allow us to organize our code in a specific manner.

But what’s the difference between them?

What is Object-Oriented Programming?

Object-Oriented Programming(OOP) let’s us organize code into units. For instance, if we are building a robot, we might have a head component, an arm component, a leg component, etc.

In our case, these components would be represented by objects, containing information such as state/attributes and also methods to alter this information.

In the above example, we created an object with name and weapon as attributes and a method.

Older programming languages were focused more on OOP but new languages seem to trend more towards functional programming.

What is functional programming?

Functional programming basically says, “let’s create some functions that accept some data, and then I’ll do some logic on it, and then I’ll return some new data or information to you.”

The goal of functional programming is to make reusable functions that can create and act on some data that they are presented with.

In the above example, we have a user with some state and a re-usable function that lets us alter that user data. In this particular example, we have a user whose account is not active. The function takes in a user, sees that this user is in fact a user, and then activates their account.

Build apps like Lego. Have more fun.

We all like playing Legos. A box of modular pieces means we can compose anything we imagine, by ourselves or with others.

Yet, we develop most our applications as monoliths, where all the code is internal, coupled, and can’t be used anywhere except in this one app. This is slow, painful, and not much fun.

But what if we could build independent components first? And then use them to compose as many applications as we like, alone or with others?

OSS Tools like Bit offer a great developer experience for building independent components and composing applications. Every component can be used in many projects, integrated with other components, and shared with your team. Give it a try →

An independently source-controlled and shared “card” component. On the right => its dependency graph, auto-generated by Bit.

Learn More


JavaScript Interview Question: Explain OOP and FP was originally published in Bits and Pieces on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Bits and Pieces - Medium and was authored by Aman


Print Share Comment Cite Upload Translate Updates
APA

Aman | Sciencx (2022-03-10T08:30:23+00:00) JavaScript Interview Question: Explain OOP and FP. Retrieved from https://www.scien.cx/2022/03/10/javascript-interview-question-explain-oop-and-fp/

MLA
" » JavaScript Interview Question: Explain OOP and FP." Aman | Sciencx - Thursday March 10, 2022, https://www.scien.cx/2022/03/10/javascript-interview-question-explain-oop-and-fp/
HARVARD
Aman | Sciencx Thursday March 10, 2022 » JavaScript Interview Question: Explain OOP and FP., viewed ,<https://www.scien.cx/2022/03/10/javascript-interview-question-explain-oop-and-fp/>
VANCOUVER
Aman | Sciencx - » JavaScript Interview Question: Explain OOP and FP. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/10/javascript-interview-question-explain-oop-and-fp/
CHICAGO
" » JavaScript Interview Question: Explain OOP and FP." Aman | Sciencx - Accessed . https://www.scien.cx/2022/03/10/javascript-interview-question-explain-oop-and-fp/
IEEE
" » JavaScript Interview Question: Explain OOP and FP." Aman | Sciencx [Online]. Available: https://www.scien.cx/2022/03/10/javascript-interview-question-explain-oop-and-fp/. [Accessed: ]
rf:citation
» JavaScript Interview Question: Explain OOP and FP | Aman | Sciencx | https://www.scien.cx/2022/03/10/javascript-interview-question-explain-oop-and-fp/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.