3 ms·
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
by Trufa 4y ago
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.
- carl_dr 4y ago> 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.
- jansan 4y agoThe 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 :)
- mikercampbell 4y agoFunctional 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.
- dopidopHN 4y agoI 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.
- joshxyz 4y agothis 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
- Rapzid 4y agoSomething 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.
- cercatrova 4y agoHave you used fp-ts?