What is the best way to concatenate strings in JavaScript?


The best and fastest way to concatenate strings in JavaScript is to use the + operator. You can also use the concat() method.

Example

You can try to run the following code to concatenate strings in JavaScript

Live Demo

<html>
   <head>
      <title>JavaScript Concatenation</title>
   </head>

   <body>
      <script>
         var str1 = "Hello";
         var str2 = "World";
         var res = str1 + str2;
         document.write(res);
      </script>
   </body>
</html>

Updated on: 13-Jan-2020

801 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements