---
category: [Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: [Extend, PMD Scripting, Scripts]
nav: wcp_docs
parent_url: /wcp_docs/
title: mapKey (closure)
layout: subsection
---

## <a id="section_m3p_myb_5db"></a>Description

Calls the specified function on every element of the map, and creates a new map with the result elements. You can only modify the key. The values will remain the same. Note that the size of a map can change if the transformed keys have duplicate values.

## <a id="section_cyq_j1m_zsb"></a>Return Type

`Map`

## <a id="section_dz5_pwg_5db"></a>Instance Method Syntax

```
thisMap.mapKey(closure)
```

<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>closure</td><td>The function called for each map element. <p>Within a closure, you can't redefine the variables that are declared outside the closure.</p></td></tr></tbody></table><br/>

<b>Example</b>

`{'a':1, 'b':2}.mapKey(k => {k.upperCase()})`

Returns `{'A':1, 'B':2}`

## <a id="section_njs_xzl_zsb"></a>Namespace Function Syntax

```
map:mapKey(map, closure)
```

<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>map</td><td>The input Map.</td></tr><tr><td>closure</td><td>The function called for each map element.</td></tr></tbody></table><br/>

