How to use pure javascript to achieve shallow copy and deep copy of an object instead of using es6

504 Gateway Time-out

504 Gateway Time-out


nginx
Mar.28,2021

shallow copy:

function shalowCopy(obj) {
    return {...obj}
}

Deep copy

function deepCopy(obj) {
    return JSON.parse(JSON.stringify(obj))

}


< H2 > update < / H2 >

you can take a look at this article

.

shallow copy: Object.assign {.obj}
Deep copy: copy layer by layer, pushState , JSON.parse+JSON.stringify


which way to achieve deep copy is efficient?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ac96-345f0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ac96-345f0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?