Using Maps in JavaScript
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.
Task | Action Script / JavaScript | Additional 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"); | |
let myMap = new Base_Components_Basic_Behavior_Map_Map(myArray, "name"); Building a map from an array:
CODE
| ||
Retrieving an item from a map | set anObject = myMap.getMapValue("my key"); | |
let value = myMap.getEntry('my key'); | ||
Getting map entries | set anArray = myMap.getMapEntries(); | |
let mapEntries = myMap.getEntries(); | ||
Adding a new element to a map | set anObject = myMap.setMapValue("my key", "my value"); |
|
myMap.setEntry('my key', 'my value'); | ||
Removing an item from a map | set deletedObject = myMap.removeMapValue("my key"); | |
let removed = myMap.removeEntry('my key'); |