4 ms·
Thank you very much for the explanation! I was confused because I didn't realize that, actually, a class in ES6 is just a variable. Also, I am not used to the
by 6t6t6 11y ago
Thank you very much for the explanation!
I was confused because I didn't realize that, actually, a class in ES6 is just a variable. Also, I am not used to the decorator pattern. Now it makes sense.
- azernik 11y agoIt's even worse - classes in ES6 are just functions (their constructors); 'obj = new Class()' is just sugar for 'obj = {}; Class.bind(obj)()'. So if you leave off the "new", you'll end up clobbering whatever 'this' defaults to, which is usually the global window object.