Loading, please wait...

Operators

String Operators

The most useful string operator is termed as Concatenation, which is represented by the + sign.

Concatenation Operator (+) is useful in concatenates multiple strings values in order to get the desired output which is the union of the strings.

If we add a string and numbers then it returns a string.

 

Code:

<html>
<body>
<h2>The Concatenation Operator</h2>
<script>
var str1 = "Hello ";
var str2 = "TutorialsLink!";
document.write(str1 + str2);
</script>
</body>
</html>

Here, with the help of “+” operator, we also add the two strings and get the output is the union of two strings.

 

Output:

 

 

 

 

The following string operators are as follows:

 

Operator

Description

               =

             Assignment

               +

             Concatenate

              +=

     Concatenate and Assign