How to use String concat() Method In Javascript
The concat() method is used to join two or more strings without changing the original strings and returning a new string.
Syntax:
str1.concat( str2, str3, . . . , strN )
Example: In this example, we will concat the given string using the strings concat() method.
// JavaScript concat() method to
// merge strings together
// Original string
let str = 'Geeks';
// Joining the strings together
let value = str.concat('for', 'Geeks');
console.log(value);
Output
w3wiki
How to Concatenate Strings in JavaScript ?
String concatenation refers to combining multiple strings into a single string. This operation is commonly used in programming to create dynamic strings by joining text fragments or variables.
Approaches to Concate String in JavaScript:
Table of Content
- Using String concat() Method
- Using JavaScript + Operator
- Using JavaScript Array join() Method
- Using Template Literals (Template Strings)