Subj : Re: define new function in Class String (Spidermonkey) To : Blaubaer From : Brendan Eich Date : Tue Jan 04 2005 11:00 pm Blaubaer wrote: > I want to add the function sprintf to the String type. > var a = new String(); > a.sprintf("Integer: %d", 1); > > My function sprintf works, an returns the result, but I also want to change > the value of "a". That's wastefully expressed. Strings are not objects in JS (string is a primitive type: typeof "hi" == "string", typeof new String("hi") == "object"). It requires var a = new String() before the guts of the idea, for no purpose. It would be better to make a global sprintf function, or if you want to put it in a poor-man's namespace, make it a static: String.sprintf. /be .