What is the best way to concatenate strings in JavaScript?

JavascriptWeb DevelopmentFront End Technology

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>
raja
Published on 18-Jan-2018 13:14:49
Advertisements