Like in Action Script (see section Map Operations), you can also use maps in JavaScript. You can build/create a map, add new elements to a map, retrieve and remove items from a map and get map entries. Maps can also be used as input/output parameters to a JavaScript operation.

The following tables shows some map task and their implementation with Action Script and JavaScript.

TaskAction Script / JavaScriptAdditional Information
Creating a new map
create myMap; 

let myMap = new Base_Components_Basic_Behavior_Map_Map();
Building a map from an array
set myMap = myArray.buildMap("name");
See buildMap() Operation for more.

let myMap = new Base_Components_Basic_Behavior_Map_Map(myArray, "name");

Building a map from an array
let header = new Base_Components_Basic_Behavior_Map_Entry();
entry1.name = 'key1';
entry1.value = 'value1';

let entry2 = new Base_Components_Basic_Behavior_Map_Entry();
entry2.name = 'key2';
entry2.value = 'value2';

let myArray = new Array();
myArray.push(entry1);
myArray.push(entry2);

let myMap = new Base_Components_Basic_Behavior_Map_Map(myArray, "name");
Retrieving an item from a map
set anObject = myMap.getMapValue("my key");
See getMapValue() Operation for more.
let value = myMap.getEntry('my key');
Getting map entries
set anArray = myMap.getMapEntries();
See getMapEntries() Operation for more.
let mapEntries = myMap.getEntries();
let entryValue = mapEntries[0].value;
Adding a new element to a map
set anObject = myMap.setMapValue("my key", "my value"); 
  • All simple types except Blob can be used as a key for the map.
  • All values are allowed, except arrays and anonymous objects.

See setMapValue() Operation for more.

myMap.setEntry('my key', 'my value');
Removing an item from a map
set deletedObject = myMap.removeMapValue("my key");
See removeMapValue() Operation for more.
let removed = myMap.removeEntry('my key'); 
  • No labels