by azangru · 9y ago · 0 comments
class Person {
get isImmortal() {
return false; // noone is immortal
}
}
p = new Person();
p.isImmortal
// >>> false
p.isImmortal = true;
p.isImmortal
// >>> false
I mean, even plain untyped JavaScript can do that!And sure, Object.freeze exists, but almost none of the JS code I've seen uses it. And what's the point really when assignments to frozen fields don't even throw an exception, just fail silently. Same for getters. None of those tricks are gonna make JS into a good language in the eyes of people who don't for whatever reason consider it good already.