August 1999
Intermediate to advanced
1488 pages
72h 53m
English
dictionaryobj.Exists(key)
The Exists() method of the Dictionary object determines if an item exists in the dictionary based on the key that is passed in to the method. If key exists, true is returned, otherwise false is returned from the method.
Listing 9.18 creates a dictionary and determines if any fruits that begin with "s" are in the dictionary.
<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"); if(fruits.Exists("S")) document.write("The ... |
Read now
Unlock full access