Dictionary.Add()

JScript3.0+Syntax

							dictionaryobj.Add(key, item)
						

Description

The Add() method of the Dictionary object adds new items to the dictionary using key, item pairs. The item can be of any type, but the key cannot be an array. Nothing is returned from this method.

Example

Listing 9.16 creates a fruit dictionary and then uses the Add() method to add fruit items to the dictionary.

Listing 9.16 Create and Add Items to a Fruit 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("O","orange");
</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.