This is a simple example of enter/update/exit in d3js.
2 arrays - of differing length - are used to generate alternating sequences of bubbles.
.enter() creates the initial join of data to elements, creating one circle element for every data element in the array.
After the button is clicked, the alternative array is rejoined to the graphical elements.
Because each array is of a different length, this means we must use .exit() to remove any circle elements no longer needed and create any new circle elements by using .enter().
Once all circle elements are properly defined, we can then update the radius of each circle, new and old, according to its value in the new array.
For more details on enter/update/exit, see this useful article by Mike Bostock, creator of d3js.