Open this example in the interactive library
Source code
class Pair {
constructor(left, right) {
Object.assign(this, { left, right });
}
*[Symbol.iterator]() {
yield this.left;
yield this.right;
}
}
console.log([...new Pair("x", "y")]);
Sample output
[ 'x', 'y' ]
