I would like to define a prototype on String that is a self-invoking function
String.prototype.overEstimatedLength = (function() {
return this.length + 12345
})()
and then use it like this
'hello world'.overEstimatedLength
Unfortunately, this doesn't work. Is something like that syntactically possible and why is the example above not working?
Note: I know that property definition would be more appropriate (such as a Getter), I'm specifically interested in self-invoking functions.