format
typescript
HashSet.forEach(callback)class: HashSet
description
Iterates through a collection.
parameter
| param_name | type | description |
|---|---|---|
| callback | Callback | The callback function. |
reture
| type | description |
|---|---|
void |
code example
typescript
let myHashSet = new HashSet<String>(String);
// Add elements to myHashSet
myHashSet.Add("apple");
myHashSet.Add("banana");
myHashSet.Add("orange");
let otherHashSetObj = new HashSet<String>(String);
let callback = (item: String): void => {
otherHashSetObj.Add(item);
}
// Iterate through the collection and add elements from myHashSet to otherHashSetObj
myHashSet.forEach(callback);