How to rewrite classes using closures in JavaScript
11–20 of 58 posts
Re: How to rewrite classes using closures in JavaScript
#12class Foo { #ImPrivate = true; #meToo() { if(this.#ImPrivate) cantTouchThis(); } }
new Foo().#meToo() === BOOM
Also with using closures for "classes" takes up a whole lot more memory because new instances off all the closures are created for each instance of the class.
Re: How to rewrite classes using closures in JavaScript
#13Re: How to rewrite classes using closures in JavaScript
#14Just because of your personal opinions and certain things that don't matter in the end, you want to ruin everybody's development experience.
The proposed solution is way uglier than the standard syntax, and you'll be lucky to get any intellisense or type checking out of it.
Re: How to rewrite classes using closures in JavaScript
#15[0] - https://stackoverflow.com/questions/2497801/closures-are-poo...
Re: How to rewrite classes using closures in JavaScript
#16what does "bloat" mean in this sentence? people use "bloat" liberally nowadays.
Re: How to rewrite classes using closures in JavaScript
#17Chastised, Anton took his leave from his master and returned to his cell, intent on studying closures. He carefully read the entire "Lambda: The Ultimate..." series of papers and its cousins, and implemented a small Scheme interpreter with a closure-based object system. He learned much, and looked forward to informing his master of his progress.
On his next walk with Qc Na, Anton attempted to impress his master by saying "Master, I have diligently studied the matter, and now understand that objects are truly a poor man's closures." Qc Na responded by hitting Anton with his stick, saying "When will you learn? Closures are a poor man's object." At that moment, Anton became enlightened.
Re: How to rewrite classes using closures in JavaScript
#18Re: How to rewrite classes using closures in JavaScript
#19 console.log(`Average height for dogs is ${AVERAGE_HEIGHT_FT} kg`);
Height in kg? ;D