You may be interested to read some previous discussions around this topic: - https://esdiscuss.org/topic/structured-clones - https://esdiscuss.org/topic/the-structured-clone-wars - https://esdiscuss.org/topic/object-clone-not-quite-a-proposal - https://esdiscuss.org/topic/object-equals-and-object-clone
On Fri, Dec 7, 2018 at 6:00 AM Harry Manchanda <[email protected]> wrote: > Heya, I tried before to write this but seems like I wasn't subscribed. Now > seems like I subscribed so posting it again... > > So here we go, > > I am posting this after an aftermath of a Github Issue. See => > https://github.com/tc39/proposals/issues/150 > > I would like the JavaScript (ECMAScript) Spec to include built-in > `deepCopy/deepClone` feature. > > Please note that based on the response at Github Issue and also > considering that the top 3 npm packages for cloning have over 100k weekly > downloads I am very positive on this and should be really considered. > > I think we have two approaches to consider for same > > 1. Object Oriented approach > > ```js > // Object.prototype.deepCopy(), Array.prototype.deepCopy(), etc > > const harry = { > name: 'Harry Manchanda', > age: 25, > social: [ > { > website: 'twitter', > username: '@harmanmanchanda', > }, > { > website: 'facebook', > username: 'IamManchanda', > }, > ], > }; > > const dev = harry.deepCopy(); > dev.social[1].website = 'github'; > ``` > > 2. Functional Programming approach > > ```js > // Object.deepCopy(value) > // Value expects array, objects and primitives > > const harry = { > name: 'Harry Manchanda', > age: 25, > social: [ > { > website: 'twitter', > username: '@harmanmanchanda', > }, > { > website: 'facebook', > username: 'IamManchanda', > }, > ], > }; > > const dev = Object.deepCopy(harry); > dev.social[1].website = 'github'; > ``` > > > Reason why I think so strongly that everyone in javascript community needs > this is this > > => https://gist.github.com/search?l=JavaScript&q=deepcopy > => https://gist.github.com/search?l=JavaScript&q=deepclone > => https://github.com/search?l=JavaScript&q=deepcopy&type=Repositories > => https://github.com/search?l=JavaScript&q=deepclone&type=Repositories > > > *Thanks,* > > *Harman Singh Manchanda ( Harry )* > *Open Source Team Member - Zurb Foundation > <https://foundation.zurb.com/get-involved/yetinauts.html>* > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

