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
-
magicMirror10640247dYes. It can also monkey patch classes and add methods to Object instances.
Why, you ask?
Because JS. -
typosaurus12154247dI really don't see the point programming it like this. But anyway, this could be seen as a factory
-
ElectricCoffee3356247d@kiki I'm already a functional programmer by heart. I eat closures for every meal of the day
-
AlgoRythm50240247d@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. -
AlgoRythm50240247dBy 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.
-
AleCx0427705247d@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-wu679247dIt'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.
-
webketje2212246d@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
-
ElectricCoffee3356244d@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