3 ms·
They create a class, then they wrap the class in a class. A class in javascript is just a variable, after all. I think, personally, I'd've called the initial
by mst 11y ago
They create a class, then they wrap the class in a class.
A class in javascript is just a variable, after all.
I think, personally, I'd've called the initial class ScoreGuts or something, or gone with a different syntax that returned the class as a value, but ... eh. It's really not that big a deal.
- 6t6t6 11y agoNow I understand. Thank you! > I think, personally, I'd've called the initial class ScoreGuts or something Well, maybe the point is that the original class becomes "useless" once it has been "decorated"; so it doesn't make sense that it has its own name. But it's is also true that, once you get used to program using FP style, mutating variables like this feels "weird".
- mst 11y agoYeah, that would seem like the motivation, but it feels a bit weird to me too. It occurs to me that you could probably do something like Score = do_the_decoration((function () { class Score ... { ... } return Score; )()); but that's not exactly 100% better, just weird to a different subset of people :)
- 6t6t6 11y ago> but that's not exactly 100% better, just weird to a different subset of people Lol!