Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022

JavaScript to Concatenate Strings

To concatenate means to connect together. If you need to concatenate two or more strings, you can use the String object's concat method, as shown below.

<script type="text/javascript">
var firstString = "Now is the time for all good men ";
var secondString = "to come to the aid of their country.";

var myString = firstString.concat(secondString);

In fact you can use the concat method to connect any number of strings together by separating the strings names with commas, using the syntax shown below.

string.concat(string1, string2, ... ,stringN)

In fact, using the concat method is not strictly necessary, as you can use the "+" operator to concatenate strings as shown below.

<script type="text/javascript">
var strFirst = "John";
var strLast = "Kennedy";
var strFull = strFirst + "F." + strLast;

You can use the "+" operator combined with the "=" operator to concatenate a character or string of characters to the end of an existing string as shown below.

<script type="text/javascript">
var strPatriot = "Now is the time for all good men ";
strPatriot += "to come to the aid of their country.";

Using this "+=" operator combination, you can concatenate groups of characters to create very long strings, as shown below.

<script type="text/javascript">
var strRabbit = "So Alice was considering, in her own mind, ";
strRabbit += "whether the pleasure of making a daisy-chain ";
strRabbit += "would be worth the trouble of getting up and ";
strRabbit += "picking the daisies, when suddenly a white ";
strRabbit += "rabbit with pink eyes ran close by her.";

As you can see, there are several ways to concatenate, or connect together, stings of characters.

More Java Script Code:
• The Conditional Operator
• Get Webpage File Date and File Size
• Convert a Number to a String
• Determine Minimum and Maximum
• The continue Statement
• Define Lines in a String
• JavaScript Character Escape Sequences
• Include a Quote Character in a String
• Convert a String to a Number
• Find a Character or a Substring Within a String

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Web Design Sections

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2017 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268