Languages
[Edit]
EN

JavaScript - String concat() method example

6 points
Created by:
Root-ssh
178170

Concat method is used to join two or more strings in JavaScript. The method appends passed arguments to right side of string. 


1. Documentation

Edit
SyntaxString.prototype.concat([string2[, string3[, ..., stringN]]])
Parametersstring2...stringN - optional string type agruments (primitive value).
Result

Combining the string on which the function was called and arguments of the string type (primitive values). Further arguments to the function are appended on the right.

If no arguments passed it returns same string.

Descriptionconcat takes zero or more arguments and returns containing the text of the combined strings.

2. Alternative concatenation approach example

Edit

Note: it is strongly recommended to use += operator instead concat() method to get better peformance of operations.

3. Concatenation performance example

Edit

In this section presented program execution time depends of JavaScript implementation.

Note: some browsers can be optimized with concat() method.

 

Alternative titles

  1. JavaScript - String.prototype.concat() documentation with examples
  2. js - String concat() method documentation with examples
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - String (documentation)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join