home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeActionScript: The Definitive GuideSearch this book

11.6. Named Array Elements

Elements are usually numbered but can also be named. Using named elements we can emulate so-called associative arrays or hashes. Note that named array elements cannot be manipulated by the Array methods ( push( ), pop( ), etc., covered later) and are not considered part of the numbered element list. An array with one named element and two numbered elements will have a length of 2, not 3. To access all the named elements in an array, therefore, we must use a for-in loop (discussed in Chapter 8, "Loop Statements"), which lists both named and numbered elements.

11.6.2. Removing Named Elements

To rid an array of an unwanted named element, we use the delete operator, which was introduced in Chapter 5, "Operators":

delete arrayName.elementName

Deleting a named element destroys both the element value and the element container, freeing up any memory being occupied by the element and its contents. (Contrast this with the delete operator's behavior for numbered elements, where it simply clears the value but leaves the container intact.)



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.











??????????????@Mail.ru