Skip to content

Commit

Permalink
string.concat() is not useful (#37122)
Browse files Browse the repository at this point in the history
* Update string/concat/index.md

Add {{optional_inline}}, same as array/concat

* Update index.md

---------

Co-authored-by: Joshua Chen <[email protected]>
  • Loading branch information
Yanko1013 and Josh-Cena authored Dec 6, 2024
1 parent 75c5e27 commit c7ee557
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ the string arguments to this string and returns a new string.
## Syntax

```js-nolint
concat()
concat(str1)
concat(str1, str2)
concat(str1, str2, /* …, */ strN)
Expand All @@ -24,7 +23,7 @@ concat(str1, str2, /* …, */ strN)
### Parameters

- `str1`, …, `strN`
- : One or more strings to concatenate to `str`.
- : One or more strings to concatenate to `str`. Though technically permitted, calling `String.prototype.concat()` with no arguments is a useless operation, because it does not result in observable copying (like {{jsxref("Array.prototype.concat()")}}), since strings are immutable. It should only happen if you are [spreading](/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) an array of strings as arguments, and that array happens to be empty.

### Return value

Expand Down

0 comments on commit c7ee557

Please sign in to comment.