deep clone javascript object
JSON.parse(JSON.stringify(object))const deepCopyFunction = (inObject) => {
let outObject, value, key
if (typeof inObject !== "object" || inObject === null) {
return inObject // Return the value if inObject is not an object
}
// Create an array or object to hold the values
outObject = Array.isArray(inObject) ? [] : {}
for (key in inObject) {
value = inObject[key]
// Recursively (deep) copy for nested objects, including arrays
outObject[key] = deepCopyFunction(value)
}
return outObject
}JSON.parse(JSON.stringify(o))
Also in JavaScript:
- npm check updates
- react native text input next field hooks focus
- how to get the value of radio button in jquery
- fetch download blob file
- javascript find duplicate in array
- p5.js put canvas in specific place
- sleeping in js
- javascript check if element has class
- Javascript string compression
- how to delete object property of array javascript
- react how to create range
- javascript .tolowercase
- javascript find the longest string in array
- react history listen get previous location
- synchronous vs asynchronous functions javascript
- flatlist footer react native
- javascript add div to body with class
- javascript date
- how to access any argument in javascript
- dracula theme color scheme windows terminal app
- call local function javascript
- universal apollo kit
- hidden jquery
- javascript date to string