3 ms·
He more recently espoused what he calls "class-free object oriented programming," where you use closures for everything instead of prototypes. This uses more m
by MathMonkeyMan 2y ago
He more recently espoused what he calls "class-free object oriented programming," where you use closures for everything instead of prototypes. This uses more memory, but he says that it doesn't matter.
I do like writing Javascript that way, though:
function Thing(otherThing) {
const self = otherThing || {};
self.method1 = function () { /* ... */ };
// self. [...]
return self;
}
function main() {
// no `new`, no `this`
const thing = Thing();
// ...
}