Skip to content

Latest commit

 

History

History
76 lines (60 loc) · 2.35 KB

File metadata and controls

76 lines (60 loc) · 2.35 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
concat Method (Array) (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
concat
JavaScript
TypeScript
DHTML
concat method (array)
Concat method
bc2b4a6a-209e-4d59-8c24-59db01d53b1e
16
mikejo5000
mikejo
ghogen

concat Method (Array) (JavaScript)

Combines two or more arrays.

Syntax

  
array1.concat([item1[, item2[, . . . [, itemN]]]])   

Parameters

array1
Required. The Array object to which the other arrays are concatenated.

item1,. . ., itemN
Optional. Additional items to add to the end of array1.

Remarks

The concat method returns an Array object containing the concatenation of array1 and any other supplied items.

The items to be added (item1 itemN) to the array are added, in order, starting from the first item in the list. If one of the items is an array, its contents are added to the end of array1. If the item is anything other than an array, it is added to the end of the array as a single array element.

Elements of source arrays are copied to the resulting array as follows:

  • If an object is copied from any of the arrays being concatenated to the new array, the object reference continues to point to the same object. A change in either the new array or the original array will result in a change to the other.

  • If a number or string value is added to the new array, only the value is copied. Changing the value in one array does not affect the value in the other.

Example

The following example shows how to use the concat method when used with an array:

var a, b, c, d;  
a = new Array(1,2,3);  
b = "dog";  
c = new Array(42, "cat");  
d = a.concat(b, c);  
document.write(d);  
  
//Output:   
1, 2, 3, "dog", 42, "cat"  
  

Requirements

[!INCLUDEjsv3]

See Also

concat Method (String)
join Method (Array)