I was looking at Windows Script Host code that runs in JScript 5.8 and I noticed this construct:
function String.prototype.foo() { ... }
I can't find any documentation about it! I'm fairly sure this is not legal in EcmaScript, so it has to be a Microsoft-only extension. Does anyone have any links explaining its design and semantics?
The JScript team released a draft of a document on their blog called "JScript Deviations from ES3" that describes this syntax among others.
From section 4.4:
JScript permits function names to be qualified. This allows for
function foo.prototype()
to be syntactic sugar forfoo.prototype = function (){}
Note that the object on LHS of the '.' must already be defined.
On this post from IEBlog about IE9 and ECMAScript 5 compatibility, they mention that this syntax is not supported by IE9 standards mode. I would imagine the same holds true for later versions of IE as well.