JavaScript Glossary: String concat()
Publikováno: 17.2.2019
Basics
This method is used to join the calling string and the provided string arguments. It returns a new String object containing the calling string and the provided arguments . If no arg...
Basics
This method is used to join the calling string and the provided string arguments. It returns a new String object containing the calling string and the provided arguments . If no arguments are provided, it returns the original calling string.
"Hello".concat(" World")
// "Hello World"
https://scotch.io/embed/gist/3586da5ad6ad7198f909cdcfaf95687e
The concat()
method:
- Takes values as parameters
- Appends specified parameters to parent String.
- Returns a new String containing the provided arguments and the calling string.
- If no argument is provided, it returns the original string.
Syntax
oldString.concat(newString2, newString3,...newStringN)
1 Parameter
newString2...newStringN These are values to be joined to the parent String. This can be a number values passed as arguments.
Returns a string
The method will return a String containing the parent String and the values specified as arguments. If no arguments are provided, it will return the calling string object.
Common Uses and Snippets
Convert numbers to a String
The concat()
method can be used to convert number arguments into a single string containing all the numbers in the same order as the argument.
https://scotch.io/embed/gist/5d8dc2e4584e2632c66c9f10e5e23e12