How to Clone an Object in JQuery ?

This content was proof-read by Grammarly. You can Try Grammary for FREE

If you are looking at cloning an object in JQuery , you can do that using the jQuery’s extend method . You can perform the shallow copy or deep copy by setting the parameters.

Below is a sample code snippet demonstrating how to clone an object in JQuery

Are you a .NET Developer planning to integrate GraphQL for .NET in your Application? Check out this book BUY & DOWNLOAD GRAPHQL.NET COOKBOOK

How to Clone an Object in JQuery ?

var ClonedObject = jQuery.extend({}, ObjectToBeCloned);

The above method performs the shallow copy .

You can set the first parameter of the extend to true to make it a deep copy.

%d bloggers like this: