MindFusion.Charting for JavaScript Programmer's Guide
IEnumerable.forEach Method
See Also
Collapse All Expand All Language Filter: All Language Filter: Multiple Language Filter: None Language Filter: C# Language Filter: Visual Basic Language Filter: Java Language Filter: JavaScript Language Filter: C++ Language Filter: XAML

C#
Visual Basic
Java
JavaScript
C++
XAML

Executes a provided function once for each element.

Namespace: MindFusion.Common.Collections
File: IEnumerable.js

## Syntax

JavaScript Copy Code
function forEach (callback, context)

### Parameters

callback

  Type: function
  function. A function to execute for each element.

context

  Type: Object
  Object. The invokation context.

## Example

The following code uses the forEach method in the event handler of the selectionChanged event of a ListView to change the background of items:

JavaScript Copy Code
listView.selectionChanged.addEventListener(listSelectionChanged); function listSelectionChanged(sender, args) { if (args.oldItems) { args.oldItems.forEach(function (item) { item.data.style.backgroundColor = ""; }); } else { args.newItems.forEach(function (item) { item.data.style.backgroundColor = "#9caac6"; }); } }

## See Also

IEnumerable Members
IEnumerable Class
MindFusion.Common.Collections Namespace