
Prototype Use Case : Design Patterns in TypeScript
Design Patterns In TypeScript (book)
https://www.amazon.com/dp/B0948BCH24 : ASIN B0948BCH24
https://www.amazon.com/dp/B094716FD6 : ASIN B094716FD6
Documentation : https://sbcode.net/typescript/prototype/#prototype-use-case
In this example, an object called document is cloned using shallow and deep methods.
I clone the documents instance properties and methods.
The object contains an array of two arrays. Three copies are created, and each time some part of the array is changed on the clone, and depending on the method used, it can affect the original object.
When cloning an object, it is good to understand the deep versus shallow concept of copying and whether you also want the clone to contain the classes methods.
#prototypePattern
#typescriptPrototype
#prototypePatternTypescript