Message from JavaScript discussions

April 2017

— This will console log all the nodes of an object down to the deepest one:

var traversal = dft(object);

var iteration =;

var flyweight = iteration.value;

while (!iteration.done) {


  iteration =;

  flyweight = iteration.value;


With flyweight being a shared state object.
Here's the inside of the traversal algorithm that implements this interface:
// Yield the Shared State Object

yield {

  loc: loc,

  tuple: tuple,

  existing: existing,

  isContainer: isContainer;


Message permanent page


What is special about this is, all the information is stored in a map and a stack, and either the caller or generator can modify that state for it's own needs

— For instance, modifying flyweight.tuple directly modifies the objects being traversed

— The tuple is an object with named properties referencing the objects being traversed at the same time and the value being iterated

Message permanent page

— So if a clone algorithm needs to use this traversal function and, say, keep parity between the clone's accessor and the original's accessor, it can simply add to the tuple, starting with the root node before calling next:

// Set Clone Object Root
tuple.clone = cloneRoot;

Message permanent page

— The tuple looks like this on the inside:

{original: [Object], search: [Object]}

and anything added to this will go to two places: 1 being a map of known nodes, and 2 being a stack which the iddfs uses for navigation

Message permanent page

— Which means... if the node is encountered again, say because multiple properties refer to it, then the tuple that was added when the node was first encountered will then be supplied back to the caller

Message permanent page

— I am also a woman :D Hello

— Not a lot of us in these groups, lol

— Are you at school for it or self learning?

— I highly reccomend taking advantage of all MDN has to offer here:

Message permanent page

— No problem :>