How to use + Operator In Javascript
The + operator adds strings and returns the concatenated string. It is the easiest method for the concatenation of two strings.
Syntax:
let str = str1 + str2
Example: In this example, we will concate two string using + operator.
// JavaScript + Operator to
// Merge Strings
// Original string
let str1 = 'Geeks';
let str2 = 'for';
let str3 = 'Geeks';
// Joining the strings together
let str = str1 + str2 + str3;
console.log(str);
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)