Dictionary.Exists()

JScript3.0+Syntax

							dictionaryobj.Exists(key)
						

Description

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.

Example

Listing 9.18 creates a dictionary and determines if any fruits that begin with "s" are in the dictionary.

Listing 9.18 Do "s" Fruits Exist in 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 ...

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.