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: 2020-01-13T08:25:31+05:30

884 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements