JSFiddle - React, Tailwind, and code Playground

by brigand

HTML

<pre id="out"></pre>

JavaScript

function spreadThing(iterable) {
  // call the special method
  const iterator = iterable[Symbol.iterator]();

  const results = [];

  let next = iterator.next();
  while (!next.done) {
    results.push(next.value);
    next = iterator.next();
  }

  return results;
}

const output = spreadThing('foo')
out.textContent += JSON.stringify(output);
out.textContent += '\n\n';
out.textContent += JSON.stringify([...'foo']);