3 ms·
I guess you still need that try-catch for back compat, though? Also note the bulk of the article is about edge cases that are unlikely to occur in practice. I
by dgreensp 6y ago
I guess you still need that try-catch for back compat, though?
Also note the bulk of the article is about edge cases that are unlikely to occur in practice. It helped me understand what they were talking about when I realized this. You aren’t actually going to inherit a private field through the prototype chain or deal with partially-initialized objects, in all likelihood.
Personally, as a TypeScript fan, my class-oriented code uses the “protected” keyword a lot, and it suits my purposes well. I don’t need runtime “safety,” and I find that truly private fields to one class (not subclasses or tests, for example) have limited use.
- inbx0 6y agoWhat platform are you targeting that supports private class fields but does not support (in a month or two I guess) the new #foo in obj syntax?