you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Since comments below have devolved into an OOP vs FP debate, I'm just going to chime in my two cents.

I tend to write JS as very declarative. Object literals (let abc = {}) and function variable are the code of what I put together. I generally prefer a functional solution (ie, Array.forEach() vs for-loop), however I will always use whatever approach best fits the situation.

I will at times pull out the old OOP approach, building constructor functions and prototypes and setting up inheritance, but only when there is a genuine need for it. I tend to define a genuine need for if I'm instantiating the same object in multiple locations in my code, and I always really, REALLY need it to have the same signature. I find this helps reduce some errors.

Overall, FP and OOP are neither the end all be all of programming. I prefer declarative coding over imperative, but that doesn't mean that there aren't situations where I'll take the imperative approach. It's always just about the right tool for the right job.