---
schema_version: "1"
id: ef3e4e822616ed47f53cc588a3cf946f5de823ce26d5d7605f40500b1a885832
title: Avoid Using Map Objects
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwc/lightning-components-security/guides/lws/lws-map.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-components-security/guide/lws-map.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: eba7e3cd8439581751dee5bc5ae0c60369056ebdef422b9db7829ae935824632
products:
  - Security for Lightning Components
  - lwc
---
# Avoid Using Map Objects

Use of the [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) object with Lightning Web Security (LWS) enabled can run into issues when the object is serialized. Instead of using a Map instance, you can use a plain JavaScript object in most cases.

If you must use maps, use the `set()` method to insert key-value pairs instead of adding custom properties. If the data passed in Map must be serialized, pass a custom [replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#replacer) function to `JSON.stringify(...)`.

Using maps in Lightning web components isn’t supported for both imperative and wired Apex calls.

**See Also**

- [_Lightning Web Components Developer Guide_: Pass Values to Apex](/docs/platform/lwc/guide/apex-call-imperative.html#pass-values-to-apex)
