# 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.md#pass-values-to-apex)
