Question on Learn D3: Animation

On this page:

What is the purpose of this line?:

const zx = x.copy(); // x, but with a new domain.

I assume the copy is to prevent mutations of x, but I don’t see where mutations are happening in that cell. Things seem to work fine if that line is eliminated and all zx is replaced with x.

Is there a better way to ask these types of questions or propose changes? Pull requests are a nice way to provide some context. Is that workflow available? (I see that’s been proposed in Notebook pull requests). Also, is it possible to share an anchored URL link to a particular cell?

In this case, yes. But if you had another cell that also modifies x, you’d be in for surprises. :slight_smile:

In Observable you’ll want to avoid side effects (a cell modifying another cell) whenever possible. I would view this as a best practice example, especially since code is often copied verbatim.

This forum is a great place to ask for help, but you can also directly add a comment to a notebook.

You can only link directly to named cells. To get the anchored link, click on a cell’s menu:

Kapture 2020-10-03 at 22.44.10

2 Likes