by Sai gowtham

How to concatenate two strings in JavaScript

In this tutorial, we are going to learn about how to concatenate two strings in JavaScript.

JavaScript offers us three different ways to concatenate or joining strings.

The first way is using the plus + operator to join two strings.

const str1= "After ";
const str2 = "noon";

const combine = str1+str2;

console.log(combine); // After noon

The second way is using the string interpolation with the help of es6 string literals.

const combine = `${str1} ${str2}`;

The third way is using the += operator to assign a string to the existing string.

let str1 = "After ";

str1 += "noon"

console.log(str1); // "After noon"

Top Udemy Courses

JavaScript - The Complete Guide 2021 (Beginner + Advanced)
JavaScript - The Complete Guide 2021 (Beginner + Advanced)
64,026 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
152,857 students enrolled
48.5 hours of video content
View Course