To be fair, it’s gotten way easier to work with it over the years and you can make it almost infinitely more complex the more libraries you throw at it. Still crazy that at some point it was disabled in browsers by default and now it’s driving so much.
Bro I’m begging you I’ve been learning JavaScript for a whole month and have been completely stuck on why higher functions exist and how would they even be useful for me. Any insight would be lovely 😔
So, in case you still want an answer to your initial question:
The reason higher functions exist, in my experience, is to modify something about the input. One of the most popular cases is currying: making the same function be callable with partial arguments. Essentially: composable functions.
It’s all about code reuse. Sometimes you have a common sequence of operations (e.g. applying a summation op to some values) that you want to apply to different data sources. If the summation operation and the data source are defined via input function arguments, that gives you a lot of generality.
You work with raw JS? I envy you on some level. I feel like TypeScript works better for my autism, what with its neat categorizations and composability, but raw JS had been my jam for a decade before that.
Sure, but like... they *feel* different, you know? I know I'm going to struggle to go back to JS if ever I have a need, 'cause "What do you MEAN there shouldn't be colons after the function name??"...
Comments
“JavaScript sucks” jokes are quite tired.
You don’t need to apologise, I’m not furious, but please don’t send them to me - especially when I discussed already having difficult emotions 💜
https://bsky.app/profile/james.claims/post/3lcoqgumcfc2w
Use the correct tool for the job that's all
“Higher” is a term from Russell’s theory of types or some such nonsense like that.
With JavaScript, you just have to skip over the cruft. Setting “use strict” helps.
The reason higher functions exist, in my experience, is to modify something about the input. One of the most popular cases is currying: making the same function be callable with partial arguments. Essentially: composable functions.