Choose where you’d like to start

deleteKey

Table of Contents

Overview

The deleteKey function deletes an element based on a specified index, or a specified key along with its value in a collection.

Syntax

To delete a key-value pair based on the key:

<collectionVariable>.deleteKey(<key>);

(OR)

To delete an element based on its index:

<collectionVariable>.deleteKey( <elementIndex> );

where,

ParameterData typeDescription
<collectionVariable>COLLECTION

The variable in which a key value pair will be deleted.

<key>-

The key which will be deleted along with the value.

No action is taken if the specified key is not found.

<elementIndex>NUMBER

The index of the element which will be deleted.

If the specified index is not found, a runtime error will be encountered.

Index starts from 0.

Examples

 productVersion = collection("Creator" : 5, "CRM" : 2);
 productVersion.deleteKey("CRM"); // deletes the specified key along with its value
 products = collection("Creator", "CRM", "Campaigns");
 products.deleteKey(1); // deletes the element "CRM"

Get Started Now

Execute