The arrayIndex is a key of an array variable. If an arrayIndex is specified instead of a variable name, the delete variable command removes that element of the array, without deleting the rest of the elements in the array.

Comments:

If you use the delete variable form, the variableName, global or local, is deleted.

The delete variable command not only removes the contents of the variable, but deletes it entirely from memory. If you delete a key from an array variable, that element of the array no longer exists as part of the variable.

Note: Local variables that are used within a handler are automatically deleted when the handler in which they are used exits.

Lessons

User Comments

Hans Behrens

Sep 8, 2009

When deleting variables, the variable MUST have been previously referenced in the script prior to being deleted. For example, if you have declared a global variable elsewhere in your stack, you may not delete it without creating a reference to it first inside the handler which deletes it.This code will not work: