From 46cbaf629970e67edee40d55e85e3106b67634f2 Mon Sep 17 00:00:00 2001 From: Peter Mawhorter Date: Fri, 17 Apr 2026 06:02:52 -0400 Subject: [PATCH] Update Array.push to note limitation of spread syntax based on functoin call arguments limit Array.push mentions using spread syntax to effectively concatenate arrays, but does not note the key limitation that this only works if the array being concatenated has fewer elements than the limit on function call arguments. I've added a note about that to the relevant section. --- .../javascript/reference/global_objects/array/push/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/en-us/web/javascript/reference/global_objects/array/push/index.md b/files/en-us/web/javascript/reference/global_objects/array/push/index.md index bf4a44ae2cf8e1d..ba3740fcd89100c 100644 --- a/files/en-us/web/javascript/reference/global_objects/array/push/index.md +++ b/files/en-us/web/javascript/reference/global_objects/array/push/index.md @@ -85,7 +85,9 @@ vegetables.push(...moreVegs); console.log(vegetables); // ['parsnip', 'potato', 'celery', 'beetroot'] ``` -Merging two arrays can also be done with the {{jsxref("Array/concat", "concat()")}} method. +Merging two arrays can also be done with the {{jsxref("Array/concat", "concat()")}} method, which will make a new combined array instead of adding to the original. + +Note: using spread syntax will only work if the number of elements in the array is less than the maximum number of function parameters. Use {{jsxref("Array/concat", "concat()")}} if you're not sure that the array you're trying to merge will be short enough. ### Calling push() on non-array objects