by Sai gowtham

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 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 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 JS 2 - The Complete Guide (incl. Vue Router & Vuex)
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
130,921 students enrolled
21 hours of video content
View Course