Questions
10.1 Not just date problems: We saw that our jsonCopy()
function has problems with dates, but that’s not all. What happens if we try to copy objects that include maps? Sets? Regular expressions? Functions?
10.2 The mote in jsonCopy’s eye…: The previous question pointed out some problems of jsonCopy()
; how does deepCopy()
fare with the same kind of objects? Can it be enhanced?
10.3 Going in circles: Objects may have circular references that point to themselves, and JSON.stringify()
will protest if dealing with such. How could you fix our deepCopy()
function to avoid that problem? We did deal with that issue in the deepFreeze()
function, but that solution cannot be used here; something different is required.
10.4 Freezing by proxying: In the Chaining and fluent interfaces section of Chapter 8, Connecting Functions, we used a proxy to get operations to provide automatic chaining. By using a proxy for setting and deleting operations, you can do your...