a>).
One way to think about it is that Visitor encapsulates recursion,
while Iterator turns everything into a loop.</p>
<p>We can implement the Iterator pattern in JavaScript using
<span class="ix-entry" ix-key="generator function;Iterator pattern!generator function" markdown="1"><a class="gl-ref" href="../glossary/#generator_function" markdown="1">generator functions</a></span>.
If we declare a function using <code>function *</code> (with an asterisk) instead of <code>function</code>
then we can use the <c