C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript String concat() MethodThe JavaScript string concat() method combines two or more strings and returns a new string. This method doesn't make any change in the original string. SyntaxThe concat() method is represented by the following syntax: string.concat(str1,str2,...,strn) Parameterstr1,str2,...,strn - It represent the strings to be combined. ReturnCombination of strings. JavaScript String concat() Method ExampleLet's see some simple examples of concat() method. Example 1Here, we will print the combination of two strings. <script> var x="TheDeveloperBlog"; var y=".com"; document.writeln(x.concat(y)); </script> Output: TheDeveloperBlog.com Example 2Here, we will print the combination of three strings. <script> var x="TheDeveloperBlog"; var y=".com"; var z=" Tutorials"; document.writeln(x.concat(y,z)); </script> Output: TheDeveloperBlog.com Tutorials Example 3In the last example, we provided the space between the strings while initializing it. Here, we will perform the similar task through the method. <script> var x="TheDeveloperBlog"; var y=".com"; var z="Tutorials"; document.writeln(x.concat(y+" "+z)); </script> Output: TheDeveloperBlog.com Tutorials
Next TopicJavaScript String
|