Re:JavaScript private class fields considered harmful
by llamaLord on Saturday April 29, 2023 @05:35PM
(#35757445)
Can you explain wrist you mean by those two examples being different things?
Do you mean that 'res' evaluates to a different result in each?
Or that when you call 'object.method()' vs calling 'm()' you would get a different 'this' context?
Re:JavaScript private class fields considered harmful
by mst on Monday May 01, 2023 @01:02PM
(#35775712)
I completely messed up one of the examples, sorry.
I meant the 'this' thing - a sibling comment to yours contains the correct code.
I've been known, for things where the object is e.g. a bag of components, to loop at construction time and replace all of my methods with pre-bound copies of themselves, but having to make a conscious decision as to whether I need to introduce that extra code (and work for the runtime per-instantiation) still makes me grumble to myself every time.