DEV Community

Cover image for The Trials and Tribulations. A Fool's Guide To Writing Functional JS (Part 4)

The Trials and Tribulations. A Fool's Guide To Writing Functional JS (Part 4)

Fahad Hossain on August 16, 2020

It's been a while since my last article so, hopefully you didn't forget what we last discussed. Throughout the last 3 articles I alluded to some ni...
Collapse
 
teamroggers profile image
Rogier Nitschelm

This is a great post! Good inspiration for people like me who enjoy declarative programming and want to keep them functions tidy and clean.

Collapse
 
fa7ad profile image
Fahad Hossain

Thanks. Glad you enjoyed it πŸ™‚

Collapse
 
pentacular profile image
Info Comment hidden by post author - thread only accessible via permalink
pentacular

There is no declarative programming here.

Collapse
 
fa7ad profile image
Fahad Hossain

@pentacular There is no actual code here. These are issues that I've faced when I was starting out, and I thought were worth sharing.

Thread Thread
 
pentacular profile image
pentacular

I'm not objecting to the article -- just pointing out that it's not declarative.

And there's nothing wrong with that.

Collapse
 
canmingir profile image
Can Mingir

Great post!

Collapse
 
ayabongaqwabi profile image
Ayabonga Qwabi

"...I can't just put a big ol' dot between two functions in JS can I? " that part put me in stiches,
Great article manπŸ™‚

Collapse
 
fa7ad profile image
Fahad Hossain

Glad you enjoyed it 😊

Collapse
 
pentacular profile image
Info Comment hidden by post author - thread only accessible via permalink
pentacular

Or you could just ... use variables.

Then you can also have sensible names.

And it won't be any less functional.

Collapse
 
fa7ad profile image
Fahad Hossain • Edited

Sure, I never said you couldn't use variables. Which of the problems do you think can be solved by using variables? I never said anything about having sensible names, are you confusing this post with some other post?

Collapse
 
pentacular profile image
pentacular

Since you're suggesting point-free composition it might be a good idea to also consider the alternative.

const deduplicated = deduplicate(data);
const inverted = invert(deduplicated);
...

Each approach has its strengths and weaknesses, after all.

Some comments have been hidden by the post's author - find out more