3 ms·
Ah yes, the good parts :) I've found understanding exactly how JS works to become more confusing with class structures. It feels like you need a PHD in JS to
by LouisSayers 5y ago
Ah yes, the good parts :)
I've found understanding exactly how JS works to become more confusing with class structures.
It feels like you need a PHD in JS to have a good grip on how it all works under the covers.
Using Crockfords closure strategy for me was quite straightforward and simple, and I've enjoyed doing:
const MyClass = {};
MyClass.new = () => {};
const instance = MyClass.new();
Which leaves all the "this." ugliness behind and provides a ruby-like instantiation.