up.util up.util.mapObject(array, mapping)
JavaScript function

Creates an object from the given array and mapping function.

Example

The mapping function is called with each array element. It must return a tuple of the object key and value:

up.util.mapObject(['alice', 'bob'], function(element) {
  return [element.toUpperCase(), element.length]
})
// result: { ALICE: 5, BOB: 3 }

Parameters

array
required

The array from which to create an object.

Each array element will become a property of the created object.

Type: Array
mapping
required

A function that is called with each array element.

It must return a tuple of the object key and value.

Type: Function(element): Pair<string, any>