JavaScript Concatenate Strings using concat() Method

javascript string concatenation es6; In this tutorial, you will learn javascript string.concat() method with the help of definition, syntax, parameters, and examples.

JavaScript String concat()

JavaScript concat() method, which is used to add or join or combine two or more strings together and it will return a new string.

Syntax

string.concat(string1, string2, string3, ...., stringX);

Parameters of string replace method

ParameterDescription
string one, string two, string three, …, stringXThis is required. The strings to be combined or added

Ex:-

Here we will take the first example of a javascript string concat() method. We have one string original string and we will add or join two more string in the original string using the concat() method.

var originalString = "Hello, ";
var str1 = "developers!";
var str2 = " Must read this javascript string method for add two or more strings together!";

var res = originalString.concat(str1, str2);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Concatenate Strings</title>
</head>
<body>
  <script type = "text/javascript">

    var originalString = "Hello, ";
    var str1 = "developers!";
    var str2 = " Must read this javascript string method for add two or more strings together!";

    var res = originalString.concat(str1, str2);

    document.write( "Output :- " + res );

  </script>
</body>
</html>

Result of the above code is:

Output :- Hello, developers! Must read this javascript string method for add two or more strings together!

JavaScript More string Methods, You may like

  1. javaScript Replace() |javaScript String Replace All
  2. Remove First Character From String Javascript
  3. javaScript String Contains | String includes() Method
  4. Remove Last Character From String Javascript
  5. JavaScript String Methods List | JavaScript Tutorial

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *