Skip to content

Mint.utils.dictionaryForEach

Tania Shatilova edited this page Nov 10, 2015 · 1 revision

The dictionaryForEach() method executes a provided function once per dictionary element. The dictionaryForEach() method executes only for own properties of an object.

Parameters

  • dictionary - object that structured like a dictionary, for example, {a: 1, b: 2}.
  • callback - function to execute for each element, taking two arguments:
    • key - the current element's key being processed in the dictionary, and
    • value - the current element's value.

Examples

var dict = {a: 1, b: 2};

function logDictionaryElements(key, value) {
  console.log("key = " + key + "; value = " + value);
}

Mint.utils.dictionaryForEach(dict, logDictionaryElements);

// logs:
// key = a; value = 1
// key = b; value = 2

Clone this wiki locally