2009/2/10 Jim Higson <j...@333.org>: > >> > What does new String("bob") offer over normal "bob"? >> >> As far as I know, nothing. Hence my assertion that Prototype should >> treat object strings as if they were a normal string. > > Hmmm... actually I should have said "nothing I've ever found > useful" :-) > > With strings-that-look-like-strings-but-are-really-objects because > they are objects you can add properties and things to them. > > For example this works: > > var obstr = new String("foo"); > foo.titlecase = function (){ /* ... */ }; > > but not this: > > var str = "foo"; > foo.titlecase = function (){ /* ... */ }; > > But, personally, I think this is confusing the definition of strings > and you're better off either adding to String.prototype (which will > make the method usable for all strings of both types) or just > providing a titlecase function that takes a string as an argument. > > -- > Jim > blog:http://jimhigson.blogspot.com/ > web:http://wikizzle.org > > >
>>> var s_String = "foo" >>> s_String "foo" >>> s_String.titlecase = function(){return substring(this,1,1).toUpperCase() + >>> substring(this,2);} function() So, you CAN add it. I suspect it is an internal object is created and then dropped. Completely useless. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---