My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Mark Maksi

11 likes

·

198 reads

5 comments

Daniel Rodríguez Rivero
Daniel Rodríguez Rivero
Jan 12, 2024

Interfaces are specific and explicit to OOP.

Are you serious?

2
·
·4 replies
Mark Maksi
Mark Maksi
Author
·Jan 13, 2024

Thanks for pointing that out. I updated the context to make my idea more clear:

In JavaScript, we have 2 main paradigms: functional programming, and object-oriented programming. Interfaces are specific and explicit to OOP and cannot be used in functional programming.

·
Daniel Rodríguez Rivero
Daniel Rodríguez Rivero
Jan 14, 2024

Mark Maksi because you updated your article, I am assuming you are not joking. Interfaces can, and are used in functional programming. Interfaces and classes are a nice way to group behaviours, and that is not exclusive to OOP

·
Mark Maksi
Mark Maksi
Author
·Jan 14, 2024

Daniel Rodríguez Rivero I updated the post because I don’t want my readers to think that interfaces are exclusive to TypeScript.

How can Interfaxes be used in functional programming other than defining types for objects? Can you show me an example in a code snippet?

·
Daniel Rodríguez Rivero
Daniel Rodríguez Rivero
Jan 15, 2024

Mark Maksi interfaces allow some type definitions that are not possible in plain types. Not sure what is in your mind, but ojects and classes are not exclusive to OOP. In FP classes can be used to model/group behaviour, without attaching any data to it. Option, Either are defined using interfaces that any class can implement. Here you have an example: github.com/gcanti/fp-ts/blob/master/src/Opt..

·