Dictionary.Count

JScript3.0+Syntax

							dictionaryobj.Count

Description

The Count property of the Dictionary object contains the number of items in the dictionary. This property is read only, so it cannot be used to change the size of the dictionary.

Example

Listing 9.17 creates a dictionary and displays the number of items that it contains.

Listing 9.17 Number of Items 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");

document.write("There are ",fruits.Count," items in this dictionary.");

//Hide End -->
</script>
</html>
						

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.