Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For me it was as simple as when I could start doing functional programming with javascript.

I was so surprised, since I had learned the other way first that it is actually easier to teach functional approaches with teenagers.

arr.map(x => x2) was abundantly clearer than

const newArr = [] for(let i, i < arr.length, i++) { newArr.push(arr[i]2) }

And to be perfectly honest, I might have goofed the for loop.



> I might have goofed the for loop.

Yeah, you did! It should have used semi-colons. (And HN has lost the carets …)

And I agree completely with you.


Something I've started doing along with the functional is fallback assignments and relying on Set operations to be idempotent. This can tidy up by removing a lot of excess conditionals at the cost of some extra operations that are actually VERY fast so in a most cases prob won't be a problem.


Have you used fp-ts?


this is a huge milestone in my coding. i remember refactoring a bunch of my code as soon as i learned how to use map functions lol


The javascript array functions and arrow functions are a gift from heaven.

And to be perfectly honest, I might have goofed the for loop.

You did, the commas must be semicolons :)


Functional JavaScript has saved me so much. And I'm not talkin Ramda, just functional principles.

I can't tell you how much time I spent chasing a bug when it was a date that was passed by reference.

Rather than trying to keep track, I just return copies of arrays and objects and it's way easier.

Even a simple

``` function yeppers(input) => ({...input, x: 7}) ```

(An overly simple example)

has made things smoother.


I miss that ability to just pass whatever around easily in JS.

Ok… it’s Footgun prone and callback hell is real.

But I still try to obtain that in other more boring language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: