Skip to content

Latest commit

 

History

History
68 lines (54 loc) · 1.74 KB

File metadata and controls

68 lines (54 loc) · 1.74 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
splice Method (Array) (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
splice
JavaScript
TypeScript
DHTML
splice method
85fdfb13-e3d9-4c89-b524-3ccee7001c93
9
mikejo5000
mikejo
ghogen

splice Method (Array) (JavaScript)

Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

Syntax

  
arrayObj.splice(start, deleteCount, [item1[, item2[, . . . [,itemN]]]])  

Parameters

arrayObj
Required. An Array object.

start
Required. The zero-based location in the array from which to start removing elements.

deleteCount
Required. The number of elements to remove.

item1, item2,. . ., itemN
Optional. Elements to insert into the array in place of the deleted elements.

Remarks

The splice method modifies arrayObj by removing the specified number of elements from position start and inserting new elements. The deleted elements are returned as a new Array object.

Example

The following code shows how to use the splice method.

var arr = new Array("4", "11", "2", "10", "3", "1");  
arr.splice(2, 2, "21", "31");  
document.write(arr);  
  
// Output: 4,11,21,31,3,1  
  

Requirements

[!INCLUDEjsv55]

See Also

slice Method (Array)