Expanding prototype within the script

8 views
Skip to first unread message

Manfred Lutterbach

unread,
May 10, 2012, 5:00:58 AM5/10/12
to IronJS
Hallo,

first at all: IronJS is a great work!

But now I have a little problem. On github I read a thread about
expanding prototypes. There is a sample like this:

String.prototype.substr = String.prototype.substring;

It works fine but what I'm looking for is something like this:
String.prototype.startsWith = function(str) {
return this.indexOf(str) == 0;
}

But I always get a TargetInvocationException with the inner exception
IronJS.UserError {"TypeError: "}.

Where is my mistake? Or is a prototype extension with the function
keyword not supported?

Manfred

PS: Enjoy your baby
Reply all
Reply to author
Forward
0 new messages