JavaScript String concat()
In this tutorial, we will learn about the JavaScript String concat()
method with the help of examples.
The
concat()
method concatenates given arguments to the given string.
Syntax
str.concat(str1, ..., strN)
- Here
str
is a String.
Parameters
str
& strN
– One or more strings to concatenate to str.
Return Value
Returns a new string contains combined text of the strings
Example: Using concat() method
"".concat(false); "".concat({}); "".concat(null); "".concat(4, 4); const hello = "Hello"; const world = "World"; hello.concat(", ", world, "!"));
Output
false [object Object] null 44 Hello, World!
Note: The assignment operators like
+
and+=
are strongly recommended over theconcat()
method.
Browser Support
concat()
is an ECMAScript1. It is fully supported in all browsers.
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |