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

Re: I must use 'new String'

Expand Messages
  • Jordan
    Simply use: var str = String( blah ); to ensure that all of the String prototype s methods are applied. JSLint encourages this usage in this case. However,
    Message 1 of 15 , Feb 19, 2010
    • 0 Attachment
      Simply use:
      var str = String('blah');

      to ensure that all of the String prototype's methods are applied. JSLint encourages this usage in this case.

      However, rather than setting properties on strings, you might want to consider {str: 'string', id: 123} because then you're not dependent on the string being an object.

      --- In jslint_com@yahoogroups.com, "Woomla" <woomla@...> wrote:
      >
      > jslint doesn't expect to see new String, but I need it because I want to
      > set a property of the string:
      >
      > var str = new String('somestring');
      > str.id = 123;
      >
      > Or is there another way to do this?
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.