import { clone } from "@arcgis/core/core/lang.js";
Since
ArcGIS Maps SDK for JavaScript 4.0

Provides a utility method for deeply cloning objects with properties that are computed or have their own clone() method, such as Extent.

Functions

clone

Function
Type parameters
<T>

Use this method to deeply clone objects with properties that are computed or have their own clone() method. For example, if you are creating an object that stores an initial extent and a spatial reference for your application, you can use esriLang.clone(initialProps) to clone this object so that the extent and spatialReference are properly cloned.

Signature
clone <T>(elem: T): T

Parameters

ParameterTypeDescriptionRequired
elem
T

The object to be cloned.

Returns
T

A clone of the object.

Example
const esriLang = await $arcgis.import("@arcgis/core/core/lang.js");
let initialProps = {
extent: appExtent, // app initial extent
spatialReference: spatReference // app spatialReference
};
// Creates a deep clone of the object
let clonedInitialProps = esriLang.clone(initialProps);