Loading ...
Sorry, an error occurred while loading the content.

1164Re: I must use 'new String'

Expand Messages
  • Woomla
    Feb 18, 2010
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Woomla" <woomla@...> wrote:
      > I've come up with the solution below. It runs in FF and IE and it uses data hiding. By implementing toString it behaves like a regular string. Only typeof returns 'object'.
      >
      >
      > var MyString = (function ()
      > {
      > var thevalue, itself;
      > thevalue = '';
      > itself = function (value)
      > {
      > thevalue = value;
      > };
      > itself.prototype.$family = {name: 'mystring'};
      > itself.prototype.toString = function ()
      > {
      > return thevalue;
      > };
      > return itself;
      > }());


      This doesn't work. I must use this.value in function itself and toString because otherwise the value is not bound to the object and subsequent MyString objects will overwrite this value.
    • Show all 15 messages in this topic