I am trying to set up a getter on a native String in JavaScript and I can't seems to get it to work. Is this even possible?
var message = "foo";
message.__defineGetter__("length", function() {
return 3;
});
(This is for work on the Terminal)
I am trying to set up a getter on a native String in JavaScript and I can't seems to get it to work. Is this even possible?
var message = "foo";
message.__defineGetter__("length", function() {
return 3;
});
(This is for work on the Terminal)
Your question is a bit odd - why would you need to set getters when the properties you are interested in are already accessible?
That said: some of them are, some of them are not, because some of them have to stay what the ECMAscript spec says they should be for JavaScript to work properly. String's length
property is an example of an immutable property, but most toString()
properties are perfectly mutable (with hilariously detrimental results).
So the real question is "what are you trying to do that requires you to overrule the ECMAscript spec" =)