Can we really delete a class create by es6 "class"?
class myClass{}
delete myClass;
console.log(myClass); //output: class myClass{}
var myClass=0; //Uncaught SyntaxError: Identifier 'myClass' has already been declared
Delete will only delete object properties or a variable that is global.
https://stackoverflow.com/a/44694753/461412
this answer is useful. yet not perfect.
i guess you could never delete it after it's declared as an identifier, but you could wrap it into a deletable variable in the first place.
still i'm looking for a better solution. our team is trying to build a detachable modules system. deadly, any declared class is not detachable. we don't like the idea of transpiling every module we load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With