List.forEach method

0 out of 2 rated this helpful - Rate this topic

Calls the specified callback function for each element in a list.

Syntax


list.forEach(callback, thisArg);

Parameters

callback

Type: Function

A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows:

  • value: the value of the element.

  • index: the current index.

  • array: the array that contains the element.

thisArg

Type: Object

An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Return value

This method does not return a value.

Examples

The following code shows how to use the forEach method.



var array = ["ab", "cd", "ef"];

var list = new WinJS.Binding.List(array);
list.forEach(showIteration);

function showIteration(value, index, array) {
    document.write("value: " + value);
    document.write(" at index: " + index);
    document.write(" in " + array);
    document.write("<br />");
}

Requirements

Namespace

WinJS.Binding

Library

Base.js

See also

List

 

 

Build date: 12/5/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.