String.concat()

JavaScript1.2+, JScript3.0+ NES3+, Nav4+, IE4+ Syntax

							string.concat(string2)

Description

The concat() method of an instance of the String object concatenates the string in string2 to the end of string to return a new string.

Example

Listing 6.235 creates two instances of the String object and uses the concat() method to concatenate them to create a new string. The string is then displayed in an alert box.

Listing 6.235 Using the concat() Method to Concatenate Two Strings
 <script language="JavaScript1.2"> <!–– Hide // Create 2 instances of the String object and concatenate // them together. var myString1 = new String("Hello, "); var myString2 = new String("World!"); var myConcatString = myString1.concat(myString2); // ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.