String.concat() (Method)

A method for concatenating as opposed to the concatenate operator.

Availability:

ECMAScript edition - 3
JavaScript - 1.2
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Netscape Enterprise server - 3.0
Property/method value type:String primitive
JavaScript syntax:-myString.concat(aString)
Argument list:aStringA string to be concatenated to the receiving string

The concatenation operator (+) is the more common method of concatenating strings together.

This method call:

myString1.concat(myString2)

is functionally equivalent to:

myString1 + myString2

The second form is more intuitive in its meaning, and hence is recommended in favor of the concat() method.

Example code:

   <HTML>
   <HEAD>
   </HEAD>
   <BODY>
   <SCRIPT>
   myString1 = "ABCDEFGHIJKLM";
   myString2 = "NOPQRSTUVWXYZ";
   document.write(myString1);
   document.write("<BR>");
   document.write(myString2);
   document.write("<BR>");
   document.write(myString1.concat(myString2));
   document.write("<BR>");
   </SCRIPT>
   </BODY>
   </HTML>

See also:Array.concat()

Cross-references:

ECMA 262 edition 3 - section - 15.5.4.6