When to use "new String();"?

Results 1 to 2 of 2

Thread: When to use "new String();"?

  1. #1
    Join Date
    Dec 1969

    Default When to use "new String();"?

    Is it ever necessary to explicitly declare a variable as a certain data type? Is there any (other than syntactically) difference between the following two declarations?<BR><BR>var winprops = new String ("toolbar=0,location=0");<BR>var winprops = "toolbar=0,location=0";<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: When to use "new String();"?

    I don&#039;t know of any difference apart from JavaScript implementation. If my memory serves me right, JavaScript 1.0 only allowed a string variable to be declared with a new String() object, but future versions (1.1 onwards) allowed the much easier method of just putting the thing in quotes. An instance of the String() object is created automatically. I only know this because when you declare a string variable, you have access to the String() object&#039;s methods.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts