Well I hate to confess but doing JavaScript is a stress so my editors got to working and after they quit smirking turned my JavaScript into a real mess
Meouzer
Full code at parseDataString.js, which depends on typing.js. But you'll also want Stringify.js.
If x is simple-data then parseDataString(serializeSimpleData(x)) is a deep copy of x. This is analogous to what JSON does, but parseDataString() together with serializeSimpleData() is much more powerful than JSON because they can handle all simple-data including typed arrays, ArrayBuffers, DataViews, Maps, and Sets. Furthermore these two functions handle complicated constructs with the greatest of ease. You can have Sets whose members are Maps, whose keys are Arrays, and values are Booleans: The Set can also have properties that are DataViews which in turn have properties that are Maps which in turn have properties that are Numbers.
Simple data was defined in the stringification article.
Like stringify(), parseDataString() uses very complex parsing, and its code will not be displayed. We will instead give examples of deep copying by serializing an object and then deserializing the resulting string.
Open your browser's console window to see the result of the test.