Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
magicMirror10693215dYes. It can also monkey patch classes and add methods to Object instances.
Why, you ask?
Because JS. -
retoor11758215dI really don't see the point programming it like this. But anyway, this could be seen as a factory
-
ElectricCoffee3397215d@kiki I'm already a functional programmer by heart. I eat closures for every meal of the day
-
AlgoRythm50877215d@retoor a factory that when an order comes in, a new machine to create the product is automatically generated and sent to the customer.
It’s a factory factory. -
AlgoRythm50877215dBy the way OP if you tried to put some horseshit like this in my code base your review would be denied and I would also fucking kill you.
-
AleCx0428240214d@AlgoRythm if he were to put some shit like this in my codebase I would buy the man a beer.
He has seen enough, the void called to him and he is trying to make others listen. -
daniel-wu679214dIt's not exclusive to JS. It's allowed on dart/flutter too since it's actually useful sometimes. You can treat anonymous function like variable, by passing them to other widget/method, or returning them.
-
webketje2220214d@AleCx04 there are some use cases. FP higher order function. This example returns a function whose prototype is set to an anonymous class. Before React Hooks HOC's "higher order components" were all the hype, those used a similar mechanism
-
ElectricCoffee3397212d@webketje It can also be used to implement mixins by creating locally scoped class definitions from which you only "inherit" a subset of methods
Related Rants
One of my favourite things in JS is the absolutely cursed shit that it lets me do.
Did you know that you can return anonymous classes from functions?
rant
class constructor constructors
classes
js