title: Making a linked list iterable in ES6
body: <p>I have a linked list in JavaScript that I need to make iterable with a <code>for of</code> loop. I have almost done it but there seems to be no way to get the first value included in the result. Here is a simplified version:</p>
  
  <pre><code>var obj = {value: 1, next: {value: 2, next: {value: 3, next: {value: 4, next: {value: 5, next: {value: 6, next: {value:7, next: null}}}}}}};
  
  obj[Symbol.iterator] = function() {
    var current = this;
    return {
      next() {
        if (current.next !== null) {
          current = current.next;
          return {value: current.value, done: false};
        }
        return {done: true}
      }
    }
  }
  
  for (const x of obj) {
    console.log(x)
  }
  
  // this is how you get the values printed with no loop
  // console.log(obj.value + '-&gt;' + obj.next.value + '-&gt;' + obj.next.next.value)
  </code></pre>