Dictionary.Keys()

JScript3.0+Syntax

							dictionaryobj.Keys()

Description

The Keys() method of the Dictionary object returns all the items in the dictionary in an array.

Example

Listing 9.22 uses the Keys() method to retrieve all the keys that are in the dictionary.

Listing 9.22 Retrieve Array of Keys Using Keys() Method
 <html> <script language="JScript"> <!-- Hide //Create dictionary var fruits = new ActiveXObject("Scripting.Dictionary"); //define elements of dictionary fruits.Add("A","apple"); fruits.Add("B","berry"); fruits.Add("G","grape"); fruits.Add("O","orange"); //Create an array theArray = (new VBArray(fruits.Keys())).toArray(); document.write("The array contains:<br>"); //Display keys in array for (i in theArray) { document.write("theArray[",i,"]=",theArray[i],"<br>"); ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.